Add number-length word and clean cartesian-product

db4
Aaron Schaefer 2009-01-07 18:47:32 -05:00
parent 503e0a4e5f
commit 51530700f4
1 changed files with 4 additions and 1 deletions

View File

@ -56,7 +56,7 @@ PRIVATE>
>lower [ CHAR: a - 1+ ] sigma ;
: cartesian-product ( seq1 seq2 -- seq1xseq2 )
swap [ swap [ 2array ] with map ] with map concat ;
[ [ 2array ] with map ] curry map concat ;
: log10 ( m -- n )
log 10 log / ;
@ -74,6 +74,9 @@ PRIVATE>
: number>digits ( n -- seq )
[ dup 0 = not ] [ 10 /mod ] [ ] produce reverse nip ;
: number-length ( n -- m )
log10 floor 1+ >integer ;
: nth-triangle ( n -- n )
dup 1+ * 2 / ;