RosettaCodeData/Task/Hofstadter-Q-sequence/Factor/hofstadter-q-sequence.factor

8 lines
234 B
Factor
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
( 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