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

41
Task/Amb/Red/amb.red Normal file
View file

@ -0,0 +1,41 @@
Red ["Amb operator"]
findblock: function [
blk [block!]
][
foreach w blk [
if all [word? w block? get w] [return w]
if block? w [findblock w]
]
]
amb: function [
cond [block!]
][
either b: findblock cond [
foreach a get b [
cond2: replace/all/deep copy/deep cond b a
if amb cond2 [set b a return true]]
][do cond]
]
; examples
x: [1 2 3 4]
y: [4 5 6]
z: [5 2]
print amb [x * y * z = 8]
print [x y z]
a: ["the" "that" "a"]
b: ["frog" "elephant" "thing"]
c: ["walked" "treaded" "grows"]
d: ["slowly" "quickly"]
print amb [
all [
equal? last a first b
equal? last b first c
equal? last c first d
]
]
print [a b c d]