September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,74 +1,76 @@
|
|||
#define system.
|
||||
#define system'routines.
|
||||
#define extensions.
|
||||
#define extensions'routines.
|
||||
import system'routines.
|
||||
import extensions.
|
||||
import extensions'routines.
|
||||
|
||||
#symbol joinable = (:aFormer:aLater)
|
||||
[ (aFormer@(aFormer length - 1)) == (aLater@0) ].
|
||||
joinable = (:aFormer:aLater)(aFormer[aFormer length - 1] == aLater[0]).
|
||||
|
||||
#symbol dispatcher =
|
||||
dispatcher =
|
||||
{
|
||||
eval : anArray &func2:aFunction
|
||||
eval object:anArray func2:aFunction
|
||||
[
|
||||
^ aFunction eval:(anArray@0):(anArray@1).
|
||||
^ aFunction eval(anArray[0],anArray[1]).
|
||||
]
|
||||
|
||||
eval : anArray &func3:aFunction
|
||||
eval object:anArray func3:aFunction
|
||||
[
|
||||
^ aFunction eval:(anArray@0):(anArray@1):(anArray@2).
|
||||
^ aFunction eval(anArray[0], anArray[1],anArray[2]).
|
||||
]
|
||||
|
||||
eval : anArray &func4:aFunction
|
||||
eval object:anArray func4:aFunction
|
||||
[
|
||||
^ aFunction eval:(anArray@0):(anArray@1):(anArray@2):(anArray@3).
|
||||
^ aFunction eval(anArray[0],anArray[1],anArray[2],anArray[3]).
|
||||
]
|
||||
|
||||
eval : anArray &func5:aFunction
|
||||
eval object:anArray func5:aFunction
|
||||
[
|
||||
^ aFunction eval:(anArray@0):(anArray@1):(anArray@2):(anArray@3):(anArray@4).
|
||||
^ aFunction eval(anArray[0],anArray[1],anArray[2],anArray[3],anArray[4]).
|
||||
]
|
||||
|
||||
}.
|
||||
|
||||
#class AmbValueCollection
|
||||
class AmbValueCollection
|
||||
{
|
||||
#field theCombinator.
|
||||
object theCombinator.
|
||||
|
||||
#constructor new &args:Arguments
|
||||
constructor new args:Arguments
|
||||
[
|
||||
theCombinator := SequentialEnumerator new &args:Arguments.
|
||||
theCombinator := SequentialEnumerator new args:Arguments.
|
||||
]
|
||||
|
||||
#method seek : aCondition
|
||||
seek : aCondition
|
||||
[
|
||||
theCombinator reset.
|
||||
|
||||
theCombinator seek &each: v
|
||||
[
|
||||
^ aCondition cast:%eval &to:dispatcher &with:v.
|
||||
].
|
||||
theCombinator seekEach(:v)(dispatcher eval(v,aCondition))
|
||||
]
|
||||
|
||||
#method do : aFunction
|
||||
do : aFunction
|
||||
[
|
||||
#var aResult := theCombinator get.
|
||||
(nil != aResult)
|
||||
? [ aFunction cast:%eval &to:dispatcher &with:aResult. ]
|
||||
! [ #throw InvalidArgumentException new. ].
|
||||
var aResult := theCombinator get.
|
||||
if (nil != aResult)
|
||||
[ dispatcher eval(aResult,aFunction) ];
|
||||
[ InvalidArgumentException new; raise ]
|
||||
]
|
||||
}
|
||||
|
||||
#symbol ambOperator =
|
||||
ambOperator =
|
||||
{
|
||||
for &args:Arguments
|
||||
= AmbValueCollection new &args:Arguments.
|
||||
generic for args:Arguments
|
||||
= AmbValueCollection new args:Arguments.
|
||||
}.
|
||||
|
||||
#symbol program =
|
||||
program =
|
||||
[
|
||||
ambOperator
|
||||
for &args:("the","that","a"):("frog", "elephant", "thing"):("walked", "treaded", "grows"):("slowly", "quickly")
|
||||
seek: (:a:b:c:d) [ (joinable:a:b) and:(joinable:b:c) and:(joinable:c:d) ]
|
||||
do: (:a:b:c:d) [ console writeLine:a:" ":b:" ":c:" ":d. ]
|
||||
| if &InvalidArgumentError: e [ console writeLine:"AMB is angry". ].
|
||||
try(ambOperator
|
||||
for(("the","that","a"),("frog", "elephant", "thing"),("walked", "treaded", "grows"),("slowly", "quickly"));
|
||||
seek(:a:b:c:d) ( joinable eval(a,b) && joinable eval(b,c) && joinable eval(c,d) );
|
||||
do(:a:b:c:d) [ console printLine(a," ",b," ",c," ",d) ])
|
||||
{
|
||||
on(Exception e)
|
||||
[
|
||||
console printLine:"AMB is angry"
|
||||
]
|
||||
}.
|
||||
|
||||
console readChar.
|
||||
].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue