for that specific problem your are citing, the shortest solution would be:
but perhaps you were thinking in general of a method to create lists of strings, where each element is related to the previous in some form or the other.
Unfortunately 'dup' evaluates its second argument only once, then duplicates the result. But we could generalize the 'series' function, which already offers most of what we are looking for:
(series <num-start> <func> <num-count>) as currently in:
Code: Select all
(series 1 (fn (x) (* 2 x)) 5) => '(1 2 4 8 16)
to a new syntax pattern where we can start with any expression:
(series <exp-start> <func> <num-count>) as in:
Code: Select all
(series "a" (fn (c) (char (inc (char c)))) 5) ; in future version
=> ("a" "b" "c" "d" "e")
So func could work not only on numbers but on any data-type in <exp-start>. It turns out a very small change in the existing 'series' function makes this possible and you will see this in the next version.
ps: note that 'series' also includes $idx already so you also will be able to do:
Code: Select all
(series "\000" (fn () (char (+ $idx 1))) 5) ; in future version
=> ("\000" "\001" "\002" "\003" "\004")
in this case fn() simply ingnores the incoming argument and only looks on $idx