Handbook
Glossary
encode ( text enigma -- cipher-text )
Vocabulary
enigma
Inputs
text
an
object
enigma
an
object
Outputs
cipher-text
an
object
Definition
USING:
accessors
ascii
kernel
math
sequences
sequences.extras
;
IN:
enigma
::
encode
( text enigma -- cipher-text )
0
:>
ln! enigma
cogs>>
:>
cogs enigma
reflector>>
:>
reflector text
>lower
[
97
mod
dup
special?
[
ln 1
+
ln! cogs
[
nth
]
each
reflector
nth
cogs
reverse
[
index
]
each
97
+
cogs
length
<iota>
[
6
*
1
+
ln
mod
zero?
]
filter
cogs
[
unclip
prefix
]
change-nths
]
unless
]
map
;