use iota in a few places
parent
99a120a146
commit
332bde4173
|
@ -302,7 +302,7 @@ cell-bits 32 = [
|
|||
] unit-test
|
||||
|
||||
[ t ] [
|
||||
[ 1000 [ 1+ ] map ] { 1+ fixnum+ } inlined?
|
||||
[ 1000 iota [ 1+ ] map ] { 1+ fixnum+ } inlined?
|
||||
] unit-test
|
||||
|
||||
: rec ( a -- b )
|
||||
|
|
|
@ -66,7 +66,7 @@ IN: project-euler.018
|
|||
91 71 52 38 17 14 91 43 58 50 27 29 48
|
||||
63 66 04 68 89 53 67 30 73 16 69 87 40 31
|
||||
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23
|
||||
} 15 [ 1+ cut swap ] map nip ;
|
||||
} 15 iota [ 1+ cut swap ] map nip ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@ IN: project-euler.032
|
|||
<PRIVATE
|
||||
|
||||
: source-032 ( -- seq )
|
||||
9 factorial [ 9 permutation [ 1+ ] map 10 digits>integer ] map ;
|
||||
9 factorial iota [
|
||||
9 permutation [ 1+ ] map 10 digits>integer
|
||||
] map ;
|
||||
|
||||
: 1and4 ( n -- ? )
|
||||
number>string 1 cut-slice 4 cut-slice
|
||||
|
|
|
@ -50,13 +50,13 @@ IN: project-euler.150
|
|||
615949 * 797807 + 20 2^ rem dup 19 2^ - ; inline
|
||||
|
||||
: sums-triangle ( -- seq )
|
||||
0 1000 [ 1+ [ next ] replicate partial-sums ] map nip ;
|
||||
0 1000 iota [ 1+ [ next ] replicate partial-sums ] map nip ;
|
||||
|
||||
:: (euler150) ( m -- n )
|
||||
[let | table [ sums-triangle ] |
|
||||
m [| x |
|
||||
x 1+ [| y |
|
||||
m x - [| z |
|
||||
m x - iota [| z |
|
||||
x z + table nth-unsafe
|
||||
[ y z + 1+ swap nth-unsafe ]
|
||||
[ y swap nth-unsafe ] bi -
|
||||
|
|
Loading…
Reference in New Issue