Handbook
Glossary
cmwc
Vocabulary
random
.
cmwc
Definition
USING:
math
specialized-arrays.instances.alien.c-types.uint
;
IN:
random.cmwc
TUPLE:
cmwc
{
Q
uint-array
initial:
uint-array{
}
}
{
a
integer
initial:
0
}
{
b
integer
initial:
0
}
{
c
integer
initial:
0
}
{
i
integer
initial:
0
}
{
r
integer
initial:
0
}
{
mod
fixnum
initial:
0
}
;
Methods
USING:
accessors
kernel
math
math.bitwise
random
random.cmwc
sequences.private
;
M::
cmwc
random-32*
( cmwc -- n )
cmwc
dup
mod>>
[
[
1
+
]
]
dip
[
bitand
]
curry
compose
change-i
[
a>>
]
[
[
i>>
]
[
Q>>
]
bi
nth-unsafe
*
]
[
c>>
+
]
tri
[
>fixnum
-32
shift
cmwc
c<<
]
[
cmwc
[
b>>
bitand
]
[
c>>
w+
]
bi
]
bi
dup
cmwc
r>>
>
[
cmwc
[
1
+
]
change-c
drop
cmwc
b>>
w-
]
when
cmwc
swap
[
[
r>>
]
]
dip
[
w-
dup
]
curry
compose
[
i>>
]
[
Q>>
]
tri
set-nth-unsafe
;
USING:
accessors
kernel
math
random
random.cmwc
sequences
;
M:
cmwc
seed-random
[
Q>>
>>Q
]
[
Q>>
length
1
-
>>i
]
[
c>>
>>c
]
tri
;