Change [0,b) usages to iota
parent
7155447aed
commit
ad6d8556e0
|
@ -70,7 +70,7 @@ MEMO: static-huffman-tables ( -- obj )
|
|||
280 287 [a,b] length [ 8 ] replicate append
|
||||
] append-outputs
|
||||
0 31 [a,b] length [ 5 ] replicate 2array
|
||||
[ [ length>> [0,b) ] [ ] bi get-table ] map ;
|
||||
[ [ length>> iota ] [ ] bi get-table ] map ;
|
||||
|
||||
CONSTANT: length-table
|
||||
{
|
||||
|
|
|
@ -137,7 +137,7 @@ TUPLE: jpeg-color-info
|
|||
data>>
|
||||
binary
|
||||
[
|
||||
read1 [0,b)
|
||||
read1 iota
|
||||
[ drop
|
||||
read1 jpeg> color-info>> nth clone
|
||||
read1 16 /mod [ >>dc-huff-table ] [ >>ac-huff-table ] bi*
|
||||
|
@ -198,7 +198,7 @@ MEMO: yuv>bgr-matrix ( -- m )
|
|||
{ 8 8 } coord-matrix [ { u v } [ wave ] 2map product ] map^2
|
||||
1 u v [ 0 = [ 2 sqrt / ] when ] bi@ 4 / m*n ;
|
||||
|
||||
MEMO: dct-matrix ( -- m ) 64 [0,b) [ 8 /mod dct-vect flatten ] map ;
|
||||
MEMO: dct-matrix ( -- m ) 64 iota [ 8 /mod dct-vect flatten ] map ;
|
||||
|
||||
: mb-dim ( component -- dim ) [ h>> ] [ v>> ] bi 2array ;
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ ERROR: unimplemented-color-type image ;
|
|||
prev width tail-slice :> b
|
||||
curr :> a
|
||||
curr width tail-slice :> x
|
||||
x length [0,b)
|
||||
x length iota
|
||||
filter {
|
||||
{ filter-none [ drop ] }
|
||||
{ filter-sub [ [| n | n x nth n a nth + 256 wrap n x set-nth ] each ] }
|
||||
|
|
|
@ -6,7 +6,7 @@ math.ranges math.vectors sequences sequences.deep fry ;
|
|||
IN: images.processing
|
||||
|
||||
: coord-matrix ( dim -- m )
|
||||
[ [0,b) ] map first2 [ [ 2array ] with map ] curry map ;
|
||||
[ iota ] map first2 [ [ 2array ] with map ] curry map ;
|
||||
|
||||
: map^2 ( m quot -- m' ) '[ _ map ] map ; inline
|
||||
: each^2 ( m quot -- m' ) '[ _ each ] each ; inline
|
||||
|
|
|
@ -77,7 +77,7 @@ C: <combo> combo
|
|||
dup 0 = [
|
||||
drop 1 - nip
|
||||
] [
|
||||
[ [0,b) ] 2dip '[ _ nCk _ >=< ] search nip
|
||||
[ iota ] 2dip '[ _ nCk _ >=< ] search nip
|
||||
] if ;
|
||||
|
||||
:: next-values ( a b x -- a' b' x' v )
|
||||
|
@ -104,7 +104,7 @@ C: <combo> combo
|
|||
[ combination-indices ] keep seq>> nths ;
|
||||
|
||||
: combinations-quot ( seq k quot -- seq quot )
|
||||
[ <combo> [ choose [0,b) ] keep ] dip
|
||||
[ <combo> [ choose iota ] keep ] dip
|
||||
'[ _ apply-combination @ ] ; inline
|
||||
|
||||
PRIVATE>
|
||||
|
|
|
@ -4,7 +4,7 @@ USING: accessors arrays bit-arrays fry infix kernel layouts locals math
|
|||
math.functions multiline sequences ;
|
||||
IN: bloom-filters
|
||||
|
||||
FROM: math.ranges => [1,b] [0,b) ;
|
||||
FROM: math.ranges => [1,b] ;
|
||||
FROM: math.intervals => (a,b) interval-contains? ;
|
||||
|
||||
/*
|
||||
|
@ -121,7 +121,7 @@ PRIVATE>
|
|||
[infix hash0 + (index * hash1) + ((pow(index, 3) - index) / 6) infix] ;
|
||||
|
||||
: enhanced-double-hashes ( hash0 hash1 n -- seq )
|
||||
[0,b)
|
||||
iota
|
||||
[ '[ _ _ enhanced-double-hash ] ] dip
|
||||
swap map ;
|
||||
|
||||
|
|
|
@ -47,14 +47,14 @@ PRIVATE>
|
|||
|
||||
|
||||
: euler001b ( -- answer )
|
||||
1000 [0,b) [ [ 5 mod ] [ 3 mod ] bi [ 0 = ] either? ] filter sum ;
|
||||
1000 iota [ [ 5 mod ] [ 3 mod ] bi [ 0 = ] either? ] filter sum ;
|
||||
|
||||
! [ euler001b ] 100 ave-time
|
||||
! 0 ms ave run time - 0.06 SD (100 trials)
|
||||
|
||||
|
||||
: euler001c ( -- answer )
|
||||
1000 [0,b) [ { 3 5 } [ divisor? ] with any? ] filter sum ;
|
||||
1000 iota [ { 3 5 } [ divisor? ] with any? ] filter sum ;
|
||||
|
||||
! [ euler001c ] 100 ave-time
|
||||
! 0 ms ave run time - 0.06 SD (100 trials)
|
||||
|
|
|
@ -46,7 +46,7 @@ IN: project-euler.027
|
|||
<PRIVATE
|
||||
|
||||
: source-027 ( -- seq )
|
||||
1000 [0,b) [ prime? ] filter [ dup [ neg ] map append ] keep
|
||||
1000 iota [ prime? ] filter [ dup [ neg ] map append ] keep
|
||||
cartesian-product [ first2 < ] filter ;
|
||||
|
||||
: quadratic ( b a n -- m )
|
||||
|
|
|
@ -38,7 +38,7 @@ IN: project-euler.030
|
|||
PRIVATE>
|
||||
|
||||
: euler030 ( -- answer )
|
||||
325537 [0,b) [ dup sum-fifth-powers = ] filter sum 1 - ;
|
||||
325537 iota [ dup sum-fifth-powers = ] filter sum 1 - ;
|
||||
|
||||
! [ euler030 ] 100 ave-time
|
||||
! 1700 ms ave run time - 64.84 SD (100 trials)
|
||||
|
|
|
@ -61,7 +61,7 @@ IN: project-euler.055
|
|||
PRIVATE>
|
||||
|
||||
: euler055 ( -- answer )
|
||||
10000 [0,b) [ lychrel? ] count ;
|
||||
10000 iota [ lychrel? ] count ;
|
||||
|
||||
! [ euler055 ] 100 ave-time
|
||||
! 478 ms ave run time - 30.63 SD (100 trials)
|
||||
|
|
|
@ -36,7 +36,7 @@ IN: project-euler.057
|
|||
>fraction [ number>string length ] bi@ > ; inline
|
||||
|
||||
: euler057 ( -- answer )
|
||||
0 1000 [0,b) [ drop 2 + recip dup 1 + longer-numerator? ] count nip ;
|
||||
0 1000 iota [ drop 2 + recip dup 1 + longer-numerator? ] count nip ;
|
||||
|
||||
! [ euler057 ] 100 ave-time
|
||||
! 1728 ms ave run time - 80.81 SD (100 trials)
|
||||
|
|
|
@ -60,7 +60,7 @@ IN: project-euler.081
|
|||
3dup minimal-path-sum-to '[ _ + ] change-matrix ;
|
||||
|
||||
: (euler081) ( matrix -- n )
|
||||
dup first length [0,b) dup cartesian-product
|
||||
dup first length iota dup cartesian-product
|
||||
[ first2 pick update-minimal-path-sum ] each
|
||||
last last ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue