47 lines
1.3 KiB
Plaintext
47 lines
1.3 KiB
Plaintext
[ stack ] is modulus ( --> s )
|
|
|
|
[ this ] is modular ( --> [ )
|
|
|
|
[ modulus share mod
|
|
modular nested join ] is modularise ( n --> N )
|
|
|
|
[ dup nest? iff
|
|
[ -1 peek modular oats ]
|
|
else [ drop false ] ] is modular? ( N --> b )
|
|
|
|
[ modular? swap
|
|
modular? or ] is 2modular? ( N N --> b )
|
|
|
|
[ dup modular? if [ 0 peek ] ] is demodularise ( N --> n )
|
|
|
|
[ demodularise swap
|
|
demodularise swap ] is 2demodularise ( N N --> n )
|
|
|
|
[ dup $ '' = if
|
|
[ $ '"modularify(2-->1)" '
|
|
$ "needs a name after it."
|
|
join message put bail ]
|
|
nextword
|
|
$ "[ 2dup 2modular? iff
|
|
[ 2demodularise " over join
|
|
$ " modularise ]
|
|
else " join over join
|
|
$ " ] is " join swap join
|
|
space join
|
|
swap join ] builds modularify(2-->1) ( --> )
|
|
|
|
( --------------------------------------------------------------- )
|
|
|
|
modularify(2-->1) + ( N N --> N )
|
|
|
|
modularify(2-->1) ** ( N N --> N )
|
|
|
|
( --------------------------------------------------------------- )
|
|
|
|
[ dup 100 ** + 1 + ] is f ( N --> N )
|
|
|
|
13 modulus put
|
|
10 f echo cr
|
|
10 modularise f echo
|
|
modulus release cr
|