
Is there a way to pick only a particular value from several? For example, I want to use https://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._split-path%29%29\|split-path , which returns three values, but I’m only interested in the second value. Of course, I could write (define-values (base name must-be-dir?)
(split-path original-path))
and use only name
, but I wonder if there’s a more straightforward way.

Use match-define-values

Thanks, I’ll use (match-define-values (_ base-name _)
(split-path ...))

For the record, I also found https://docs.racket-lang.org/reference/let.html#%28form._%28%28quote._~23~25kernel%29._let-values%29%29\|let-values , which is similar, but I think match-define-values
is better for my use case.

There’s also match-let-values
, FWIW

But if you don’t want to bind the value to a variable immediately, another possibility is:
(call-with-values
(lambda () <expr-here>)
(lambda xs (list-ref xs i)))
This is more useful when <expr-here>
results in a lot of values, and you don’t want to type _ _ _ _

Using qi: (define name (~> (original-path) split-path 2>))
Depending on what happens with them next, you may be able to continue the flow (edit: you only needed one value, so simplified)

I don’t know if Racket has an equivalent (a quick scan of the docs doesn’t seem to reveal one), but CL has nth-value
, so maybe.