USING: locals ;
:: next-fib-seq ( seq -- newseq )
[let | next-term [ seq 2 tail* sum ] | seq next-term suffix ] ;
:: fib-seq-exceed? ( seq -- ? )
seq peek 4000000 > ;
:: fib-seq ( seq -- newseq )
[let | next [ seq next-fib-seq ] |
next fib-seq-exceed? [ seq ] [ next fib-seq ] if ] ;
: solve ( -- )
{ 1 2 } fib-seq [ even? ] filter sum .