RosettaCodeData/Task/Intersecting-number-wheels/Quackery/intersecting-number-wheels.quackery
2023-07-01 13:44:08 -04:00

39 lines
910 B
Text

[ ]this[ ]done[
dup take behead
dup dip
[ nested join
swap put ]
do ] is wheel ( --> n )
[ ]'[
]'[ nested
' [ wheel ]
swap join
swap replace ] is newwheel ( --> )
forward is A forward is B forward is C
forward is D ( and so on, as required )
[ wheel [ 1 2 3 ] ] resolves A ( --> n )
[ wheel [ 3 4 ] ] resolves B ( --> n )
[ wheel [ 5 B ] ] resolves C ( --> n )
[ wheel [ 6 7 8 ] ] resolves D ( --> n )
20 times [ A echo sp ] cr
newwheel A [ 1 B 2 ]
20 times [ A echo sp ] cr
newwheel A [ 1 D D ]
20 times [ A echo sp ] cr
newwheel A [ 1 B C ]
newwheel B [ 3 4 ] ( As B has been used already )
( it's state may be [ 4 3 ]. )
( So we reset it to [ 3 4 ]. )
20 times [ A echo sp ] cr