I have a sequence with a known number of elements (from a pcre match) and would like to map this into lexical variables.
I can probably loop over the sequence and put every element onto the stack and then :> ( a b c d )
but is there an idiomatic way to do this ?
Oh and my sequence has more than 4 elements, so first4
doesn't cut it, although I could obviously use first4
and then first3
on a subset of the sequence.
If you are sure that's want you really want to do, you could use
firstn
fromquotations.generalizations
:But it sounds like a bad idea. It's tricky, because the lexical variables are not "real" variables, the compiler converts them into stack shuffling. That's why they don't play nice with macros and
:>
can't be called like a regular word.If you use dynamic variables it's easier: