math.vectors: changes so that some vocabs that can use math.vector words does it
parent
001acde590
commit
61ba941740
|
@ -7,8 +7,6 @@ IN: checksums.hmac
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: seq-bitxor ( seq seq -- seq ) [ bitxor ] 2map ;
|
|
||||||
|
|
||||||
: opad ( checksum-state -- seq ) block-size>> 0x5c <array> ;
|
: opad ( checksum-state -- seq ) block-size>> 0x5c <array> ;
|
||||||
|
|
||||||
: ipad ( checksum-state -- seq ) block-size>> 0x36 <array> ;
|
: ipad ( checksum-state -- seq ) block-size>> 0x36 <array> ;
|
||||||
|
@ -16,9 +14,9 @@ IN: checksums.hmac
|
||||||
:: init-key ( checksum key checksum-state -- o i )
|
:: init-key ( checksum key checksum-state -- o i )
|
||||||
checksum-state block-size>> key length <
|
checksum-state block-size>> key length <
|
||||||
[ key checksum checksum-bytes ] [ key ] if
|
[ key checksum checksum-bytes ] [ key ] if
|
||||||
checksum-state block-size>> 0 pad-tail
|
checksum-state block-size>> 0 pad-tail
|
||||||
[ checksum-state opad seq-bitxor ]
|
[ checksum-state opad vbitxor ]
|
||||||
[ checksum-state ipad seq-bitxor ] bi ;
|
[ checksum-state ipad vbitxor ] bi ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
|
|
@ -136,8 +136,8 @@ render-loc render-dim ;
|
||||||
ctline line-rect :> rect
|
ctline line-rect :> rect
|
||||||
rect origin>> CGPoint>loc :> (loc)
|
rect origin>> CGPoint>loc :> (loc)
|
||||||
rect size>> CGSize>dim :> (dim)
|
rect size>> CGSize>dim :> (dim)
|
||||||
(loc) [ floor ] map :> loc
|
(loc) vfloor :> loc
|
||||||
(loc) (dim) [ + ceiling ] 2map :> ext
|
(loc) (dim) v+ vceiling :> ext
|
||||||
ext loc [ - >integer 1 max ] 2map :> dim
|
ext loc [ - >integer 1 max ] 2map :> dim
|
||||||
|
|
||||||
loc line render-loc<<
|
loc line render-loc<<
|
||||||
|
|
|
@ -16,14 +16,11 @@ IN: benchmark.simd-1
|
||||||
: normalize-points ( points -- )
|
: normalize-points ( points -- )
|
||||||
[ normalize ] map! drop ; inline
|
[ normalize ] map! drop ; inline
|
||||||
|
|
||||||
: max-points ( points -- point )
|
|
||||||
[ ] [ vmax ] map-reduce ; inline
|
|
||||||
|
|
||||||
: print-point ( point -- )
|
: print-point ( point -- )
|
||||||
[ number>string ] { } map-as ", " join print ; inline
|
[ number>string ] { } map-as ", " join print ; inline
|
||||||
|
|
||||||
: simd-benchmark ( len -- )
|
: simd-benchmark ( len -- )
|
||||||
>fixnum make-points [ normalize-points ] [ max-points ] bi print-point ;
|
>fixnum make-points [ normalize-points ] [ vsupremum ] bi print-point ;
|
||||||
|
|
||||||
: simd-1-benchmark ( -- )
|
: simd-1-benchmark ( -- )
|
||||||
10 [ 500000 simd-benchmark ] times ;
|
10 [ 500000 simd-benchmark ] times ;
|
||||||
|
|
|
@ -39,7 +39,7 @@ M: color-preview model-changed
|
||||||
[ <color-model> <color-preview> 1 track-add ]
|
[ <color-model> <color-preview> 1 track-add ]
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
[ truncate ] map v>integer
|
vtruncate v>integer
|
||||||
first3 3dup "%d %d %d #%02x%02x%02x" sprintf
|
first3 3dup "%d %d %d #%02x%02x%02x" sprintf
|
||||||
] <arrow> <label-control>
|
] <arrow> <label-control>
|
||||||
f track-add
|
f track-add
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (c) 2012 Anonymous
|
! Copyright (c) 2012 Anonymous
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel math sequences ;
|
USING: kernel math math.vectors sequences ;
|
||||||
IN: rosetta-code.equilibrium-index
|
IN: rosetta-code.equilibrium-index
|
||||||
|
|
||||||
! http://rosettacode.org/wiki/Equilibrium_index
|
! http://rosettacode.org/wiki/Equilibrium_index
|
||||||
|
@ -35,5 +35,5 @@ IN: rosetta-code.equilibrium-index
|
||||||
[ <reversed> ] 2dip accum-left <reversed> ; inline
|
[ <reversed> ] 2dip accum-left <reversed> ; inline
|
||||||
|
|
||||||
: equilibrium-indices ( seq -- inds )
|
: equilibrium-indices ( seq -- inds )
|
||||||
0 [ + ] [ accum-left ] [ accum-right ] 3bi [ = ] 2map
|
0 [ + ] [ accum-left ] [ accum-right ] 3bi v=
|
||||||
V{ } swap dup length iota [ [ suffix ] curry [ ] if ] 2each ;
|
V{ } swap dup length iota [ [ suffix ] curry [ ] if ] 2each ;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (c) 2012 Anonymous
|
! Copyright (c) 2012 Anonymous
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel math sequences ;
|
USING: kernel math math.vectors sequences ;
|
||||||
IN: rosetta-code.long-multiplication
|
IN: rosetta-code.long-multiplication
|
||||||
|
|
||||||
! http://rosettacode.org/wiki/Long_multiplication
|
! http://rosettacode.org/wiki/Long_multiplication
|
||||||
|
@ -21,7 +21,7 @@ IN: rosetta-code.long-multiplication
|
||||||
[ * ] cartesian-map
|
[ * ] cartesian-map
|
||||||
dup length iota [ 0 <repetition> ] map
|
dup length iota [ 0 <repetition> ] map
|
||||||
[ prepend ] 2map
|
[ prepend ] 2map
|
||||||
[ ] [ [ 0 suffix ] dip [ + ] 2map ] map-reduce ;
|
[ ] [ [ 0 suffix ] dip v+ ] map-reduce ;
|
||||||
|
|
||||||
: integer->digits ( x -- xs )
|
: integer->digits ( x -- xs )
|
||||||
{ } swap [ dup 0 > ] [ 10 /mod swap [ prefix ] dip ] while drop ;
|
{ } swap [ dup 0 > ] [ 10 /mod swap [ prefix ] dip ] while drop ;
|
||||||
|
|
Loading…
Reference in New Issue