Use vectors instead of arrays in solution to Project Euler problem 2

db4
Aaron Schaefer 2008-01-18 17:11:06 -05:00
parent a3dd5cb1e6
commit ab7849f711
1 changed files with 2 additions and 2 deletions

View File

@ -22,12 +22,12 @@ IN: project-euler.002
<PRIVATE
: (fib-upto) ( seq n limit -- seq )
2dup <= [ >r add dup 2 tail* sum r> (fib-upto) ] [ 2drop ] if ;
2dup <= [ [ over push dup 2 tail* sum ] dip (fib-upto) ] [ 2drop ] if ;
PRIVATE>
: fib-upto ( n -- seq )
{ 0 } 1 rot (fib-upto) ;
V{ 0 } clone 1 rot (fib-upto) ;
: euler002 ( -- answer )
1000000 fib-upto [ even? ] subset sum ;