Module Using_AmbFunction { Enum Solution {First, Any=-1} Function Amb(way as Solution, failure) { read a c1=lambda i=0, a, (&any, &ret) ->{ any=(array(a,i),) ret=any i++ ok=i=len(a) if ok then i=0 =ok } m=stack.size if m=0 then Error "At least two arrays needed" c=c1 while m>0 { read a c1=lambda c2=c, i=0, a, (&any, &ret) ->{ any=(array(a,i),) ret=(,) : ok=false : anyother=(,) ok=c2(&anyother, &ret) ret=cons(ret, any) if ok then i++ ok=i=len(a) if ok then i=0 =ok } c=c1 : m-- } ok=false any=(,) flush while not ok ret=(,) ok=c(&any, &ret) s=stack(ret) if not failure(! s) then data ret : if way>0 then ok=true End While if empty then ret=(("",),) else ret=array([]) end if =ret } Range=lambda (a, f) ->{ for i=a to f-1: data i: next =array([]) } Baker=range(1, 5) Cooper=range(2, 6) Fletcher=range(2, 5) Miller=range(1,6) Smith=range(1,6) failure=lambda (Baker, Cooper, Fletcher, Miller, Smith)->{ if Baker=Cooper or Baker=Fletcher or Baker=Miller or Baker=Smith then =true:exit if Cooper=Fletcher or Cooper =Miller or Cooper=Smith then =true:exit if Fletcher=Miller or Fletcher=Smith or Miller=Smith then =true:exit if Miller