RosettaCodeData/Task/Hofstadter-Q-sequence/Factor/hofstadter-q-sequence.factor
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

7 lines
234 B
Factor

( scratchpad ) : next ( seq -- newseq )
dup 2 tail* over length [ swap - ] curry map
[ dupd swap nth ] map 0 [ + ] reduce suffix ;
( scratchpad ) { 1 1 } 1000 [ next ] times dup 10 head . 999 swap nth .
{ 1 1 2 3 3 4 5 5 6 6 }
502