xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:
I have attempt to implement amb function in perl, but failed. Compared to scheme, It seems that perl couldn't deal with continuation.(define (require p) (if (not p) (amb))) (define (distinct? items) (cond ((null? items) true) ((null? (cdr items)) true) ((member (car items) (cdr items)) false) (else (distinct? (cdr items))))) (define (multiple-dwelling) (let ((baker (amb 1 2 3 4 5)) (cooper (amb 1 2 3 4 5)) (fletcher (amb 1 2 3 4 5)) (miller (amb 1 2 3 4 5)) (smith (amb 1 2 3 4 5)) (require (distinct? (list baker cooper fletcher miller smith))) (require (not (= baker 5))) (require (not (= cooper 1))) (require (not (= fletcher 5))) (require (not (= fletcher 1))) (require (> miller cooper))) (require (not (= (abs (- smith fletch)) 1))) (require (not (= (abs (- fletcher cooper)) 1))) (list (list 'baker baker) (list 'cooper cooper) (list 'fletcher fletcher) (list 'miller miller) (list 'smith smith))))
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How implement AMB in perl?
by dk (Chaplain) on Apr 29, 2007 at 08:37 UTC | |
by Enlil (Parson) on Apr 29, 2007 at 09:30 UTC | |
by dk (Chaplain) on Apr 29, 2007 at 09:40 UTC | |
by halley (Prior) on Apr 30, 2007 at 12:52 UTC | |
|
Re: How implement AMB in perl?
by akho (Hermit) on Apr 29, 2007 at 11:36 UTC | |
by blazar (Canon) on Apr 29, 2007 at 12:42 UTC | |
|
Re: How implement AMB in perl?
by ambrus (Abbot) on Apr 29, 2007 at 13:52 UTC | |
by Joost (Canon) on Apr 29, 2007 at 14:32 UTC | |
|
Re: How implement AMB in perl?
by jdporter (Paladin) on Apr 30, 2007 at 14:18 UTC | |
|
Re: How implement AMB in perl?
by Moron (Curate) on May 01, 2007 at 09:13 UTC | |
|
Re: How implement AMB in perl?
by clscott (Friar) on May 02, 2007 at 00:34 UTC |