Updating contrib/math/ for latest changes
parent
7725d92f26
commit
59c64064a7
|
@ -1,7 +1,6 @@
|
||||||
IN: math-contrib
|
IN: math-contrib
|
||||||
|
|
||||||
USING: kernel sequences errors namespaces math lists vectors errors prettyprint ;
|
USING: kernel sequences errors namespaces math vectors errors prettyprint io inspector ;
|
||||||
USING: io inspector ;
|
|
||||||
|
|
||||||
: setup-range ( from to -- frange )
|
: setup-range ( from to -- frange )
|
||||||
step-size get swap <frange> ;
|
step-size get swap <frange> ;
|
||||||
|
|
|
@ -13,6 +13,13 @@ USING: errors kernel sequences math sequences-internals namespaces arrays ;
|
||||||
gcd 1 = [ "Non-trivial divisor found" throw ] unless ;
|
gcd 1 = [ "Non-trivial divisor found" throw ] unless ;
|
||||||
foldable
|
foldable
|
||||||
|
|
||||||
|
: each-bit ( n quot -- | quot: 0/1 -- )
|
||||||
|
over zero? pick -1 number= or [
|
||||||
|
2drop
|
||||||
|
] [
|
||||||
|
2dup >r >r >r 1 bitand r> call r> -1 shift r> each-bit
|
||||||
|
] if ; inline
|
||||||
|
|
||||||
: (^mod) ( n z w -- z^w )
|
: (^mod) ( n z w -- z^w )
|
||||||
1 swap [
|
1 swap [
|
||||||
1 number= [ dupd * pick mod ] when >r sq over mod r>
|
1 number= [ dupd * pick mod ] when >r sq over mod r>
|
||||||
|
|
Loading…
Reference in New Issue