Use more combinators

db4
Samuel Tardieu 2008-04-04 11:20:10 +02:00
parent 1e538ccd03
commit fe8448b4e8
2 changed files with 2 additions and 2 deletions

View File

@ -45,7 +45,7 @@ PRIVATE>
: primes-between ( low high -- seq )
primes-upto
>r 1- next-prime r>
[ 1- next-prime ] dip
[ [ <=> ] binsearch ] keep [ length ] keep <slice> ; foldable
: coprime? ( a b -- ? ) gcd nip 1 = ; foldable

View File

@ -30,7 +30,7 @@ MEMO: fn ( n -- x )
{
{ [ dup 2 < ] [ drop 1 ] }
{ [ dup odd? ] [ 2/ fn ] }
{ [ t ] [ 2/ [ fn ] keep 1- fn + ] }
{ [ t ] [ 2/ [ fn ] [ 1- fn + ] bi ] }
} cond ;
: euler169 ( -- result )