Jump to content

Intersecting number wheels: Difference between revisions

Realize in F#
(→‎{{header|REXX}}: added the REXX computer programming language for this task.)
(Realize in F#)
Line 142:
</pre>
 
=={{header|F_Sharp|F#}}==
// Wheele within wheels. Nigel Galloway: September 30th., 2019.
let N(n)=fun()->n
let wheel(n:(unit->int)[])=let mutable g= -1 in (fun()->g<-(g+1)%n.Length; n.[g]())
let A1=wheel[|N(1);N(2);N(3)|]
for n in 0..20 do printf "%d " (A1())
printfn ""
let B2=wheel[|N(3);N(4)|]
let A2=wheel[|N(1);B2;N(2)|]
for n in 0..20 do printf "%d " (A2())
printfn ""
let D3=wheel[|N(6);N(7);N(8)|]
let A3=wheel[|N(1);D3;D3|]
for n in 0..20 do printf "%d " (A3())
printfn ""
let B4=wheel[|N(3);N(4)|]
let C4=wheel[|N(5);B4|]
let A4=wheel[|N(1);B4;C4|]
for n in 0..20 do printf "%d " (A4())
printfn ""
</lang>
{{out}}
<pre>
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
1 3 2 1 4 2 1 3 2 1 4 2 1 3 2 1 4 2 1 3 2
1 6 7 1 8 6 1 7 8 1 6 7 1 8 6 1 7 8 1 6 7
1 3 5 1 4 3 1 4 5 1 3 4 1 3 5 1 4 3 1 4 5
</pre>
=={{header|Factor}}==
An attempt has been made to simplify the interface as much as possible by creating a natural literal syntax for number wheel groups. This should be useful for exploring these types of sequences in the future.
2,172

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.