Intersecting number wheels: Difference between revisions

m
→‎{{header|zkl}}: change initial data structure
(→‎{{header|zkl}}: added code)
m (→‎{{header|zkl}}: change initial data structure)
Line 465:
 
=={{header|zkl}}==
<lang zkl>fcn intersectingNumberWheelsW(wheel1, wheel2, etcwheels){ // ("A",:(a,b,"C")), ("C",:(d,e)) ...)
ws:=vm.arglistwheels.pump(Dictionary().add,fcn(w[(k,v)]){ return(w[0]k,Walker.cycle(w[1]v)) }); // new Dictionary
Walker.zero().tweak(fcn(w,wheels){
while(1){
Line 472:
if(Int.isType(w)) return(w);
}
}.fp("A",ws)) // assume wheel A exists and is always first
}.fp(wheel1[0],ws))
}</lang>
<lang zkl>wheelSets:=T( T( TDictionary("A",T(1,2,3)) ),
T( TDictionary("A",T(1,"B",2)), T("B",T(3,4)) ),
T( TDictionary("A",T(1,"D","D")), T("D",T(6,7,8)) ),
T( TDictionary("A",T(1,"B","C")), T("C",T(5,"B")), T( "B",T(3,4)) ) );
foreach ws in (wheelSets){
println("Wheel set:");
ws.pump(String,fcn(w[(k,v)]){ " %s: %s\n".fmt(w[0]k,w[1]v.concat(" ")) }).print();
println("-->",intersectingNumberWheelsW(ws.xplode()).walk(20).concat(" "));
}</lang>
{{out}}
Anonymous user