Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
20
Task/Amb/Factor/amb.factor
Normal file
20
Task/Amb/Factor/amb.factor
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
USING: backtrack continuations kernel prettyprint sequences ;
|
||||
IN: amb
|
||||
|
||||
CONSTANT: words {
|
||||
{ "the" "that" "a" }
|
||||
{ "frog" "elephant" "thing" }
|
||||
{ "walked" "treaded" "grows" }
|
||||
{ "slowly" "quickly" }
|
||||
}
|
||||
|
||||
: letters-match? ( str1 str2 -- ? ) [ last ] [ first ] bi* = ;
|
||||
|
||||
: sentence-match? ( seq -- ? ) dup rest [ letters-match? ] 2all? ;
|
||||
|
||||
: select ( seq -- seq' ) [ amb-lazy ] map ;
|
||||
|
||||
: search ( -- )
|
||||
words select dup sentence-match? [ " " join ] [ fail ] if . ;
|
||||
|
||||
MAIN: search
|
||||
Loading…
Add table
Add a link
Reference in a new issue