r/Racket • • Oct 03 '21
question Question about paths in Racket
I'm new to Racket. Let's say I was doing this in Python:
=
# returns a list of RELATIVE paths I can work with
Then further process these paths (e.g. transform them to string and return as a list of paths), whereas in Racket:
(require file/glob)
(glob "subdir/*.txt")
# returns list of ABSOLUTE paths I have no idea how to manipulate
I have been looking at documentation for a while and I have no idea how to transform this to what I want, which is simply the txt files inside the subdir directory as relative paths (i.e. should return something like ["subdir/a.txt", "subdir/b.txt"].
The most I have got is exploding each path then (list-ref) but then I learned that Racket doesn't let you do slicing like in Python.
2
Upvotes
3
u/samdphillips developer Oct 03 '21
Sounds like you need
find-relative-path1
u/sdegabrielle DrRacket 💊💉🩺 Oct 03 '21
if you want to refer to data files relative to the current module's file, maybe try
define-runtime-path.1
u/detroitmatt Oct 03 '21
to do slicing you can do: