encode ( text enigma -- cipher-text )


Vocabulary
enigma

Inputs
textan object
enigmaan object


Outputs
cipher-textan object


Definition


:: 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 ;