Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

1
Task/Amb/Zkl/amb-1.zkl Normal file
View file

@ -0,0 +1 @@
fcn joins(a,b){ a[-1]==b[0] } // the constraint

6
Task/Amb/Zkl/amb-2.zkl Normal file
View file

@ -0,0 +1,6 @@
amb(joins,
T("the","that","a"),
T("frog","elephant","thing"),
T("walked","treaded","grows"),
T("slowly","quickly")
).println();

6
Task/Amb/Zkl/amb-3.zkl Normal file
View file

@ -0,0 +1,6 @@
a:=amb.future(joins,T("the","that","a"),T("frog","elephant","thing"));
b:=amb.future(joins,T("walked","treaded","grows"),T("slowly","squacking"));
c:=amb.future(joins,a,b); // a future of futures
println(a,b,c);
c=c.noop(); // trigger the landslide, referencing c forces a result for a,b,c
println(a.noop(),b.noop(),c); // even though a has a result, it doesn't know it until we force it

10
Task/Amb/Zkl/amb-4.zkl Normal file
View file

@ -0,0 +1,10 @@
fcn amb(f,a,b,etc){
fcn(sink,f,a,b,etc){
abc:=vm.arglist[2,*]; // ((the,that),(frog,elephant))
if(abc.len()<2) return(sink.write(abc[0][0])); // back out of recursion
foreach a,b in (abc[0],abc[1]){ // Cartesian product
if(f(a,b)) self.fcn(sink,f,T(String(a," ",b)),abc[2,*].xplode());
}
}(s:=List(),vm.pasteArgs());
s
}

1
Task/Amb/Zkl/amb-5.zkl Normal file
View file

@ -0,0 +1 @@
fcn amb(f,a,b,c,etc){ Walker.cproduct(vm.pasteArgs(1)).filter1(f) }

5
Task/Amb/Zkl/amb-6.zkl Normal file
View file

@ -0,0 +1,5 @@
// [()] notation unpacks parameter list: f((1,2,3))-->a=1,b=2,c=3
fcn f([(a,b,c,d)]){ joins(a,b) and joins(b,c) and joins(c,d) }
amb(f, T("the","that","a"), T("frog","elephant","thing"),
T("walked","treaded","grows"), T("slowly","quickly")
).println();

1
Task/Amb/Zkl/amb-7.zkl Normal file
View file

@ -0,0 +1 @@
amb(fcn([(x,y,z)]){ x*x + y*y == z*z },[1..],[1..10],[1..10]).println();