|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.cscott.sdr.calls.PredicateList
public abstract class PredicateList
This class contains all the predicates known to the system.
Field Summary | |
---|---|
static Predicate |
ALL
Check that all dancers have the specified tag. |
static Predicate |
AND
Short-circuit boolean conjunction. |
static Predicate |
ARE
Check that the tagged dancers also have some other tag. |
static Predicate |
BREAKPOINT
Another synonym for TRUE , used to set breakpoints
during debugging. |
static Predicate |
EQUAL_CALL
Check the identify of a call provided as an argument. |
static Predicate |
EQUAL_NUM
Numerical equality. |
static Predicate |
EQUAL_STR
Case-insensitive string equality. |
static Predicate |
FALSE
Always false. |
static Predicate |
FORMATION
Check that the current dance state matches the specified formation (actually Matcher ). |
static Predicate |
GREATER
Numerical "greater than" comparison. |
static Predicate |
LESS
Numerical "less than" comparison. |
static Predicate |
MATCH
Case-insensitive regular expression string match. |
static Predicate |
NOT
Boolean negation. |
static Predicate |
OR
Short-circuit boolean disjunction. |
static Predicate |
PROGRAM_AT_LEAST
Check the current dance program level. |
static Predicate |
TBONED
Check whether the tagged dancers are t-boned. |
static Predicate |
TRUE
Always true. |
Constructor Summary | |
---|---|
PredicateList()
|
Method Summary | |
---|---|
static Predicate |
valueOf(String s)
Return the Predicate function with the given (case-insensitive)
name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Predicate TRUE
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr true)'); (Expr true) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true
public static final Predicate FALSE
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr false)'); (Expr false) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) false
public static final Predicate BREAKPOINT
TRUE
, used to set breakpoints
during debugging.
public static final Predicate NOT
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr not (Expr false))'); (Expr not (Expr false)) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr not (Expr true))'); (Expr not (Expr true)) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) false
public static final Predicate EQUAL_NUM
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr equal num \'"1 1/2" \'1 1/2)'); (Expr equal num '1 1/2 '1 1/2) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr equal num \'"1 1/2" \'2)'); (Expr equal num '1 1/2 '2) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) false
public static final Predicate GREATER
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr greater \'"1 1/2" \'"1 1/2")'); (Expr greater '1 1/2 '1 1/2) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) false js> c = net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr greater '2 '1 1/2)"); (Expr greater '2 '1 1/2) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true
public static final Predicate LESS
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr less \'"1 1/2" \'"1 1/2")'); (Expr less '1 1/2 '1 1/2) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) false js> c = net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr less '1 1/2 '2)"); (Expr less '1 1/2 '2) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true
public static final Predicate EQUAL_STR
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr equal str \'"abc" \'ABC)'); (Expr equal str 'abc 'ABC) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr equal str \'"abc" \'xyz)'); (Expr equal str 'abc 'xyz) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) false
public static final Predicate MATCH
js> ds = new DanceState(new DanceProgram(Program.PLUS), Formation.SQUARED_SET); undefined; js> function test(str, pat) { > let c = net.cscott.sdr.calls.ast.AstNode.valueOf( > "(Expr MATCH '"+str+" '\""+pat+"\")"); > return PredicateList.valueOf(c.atom).evaluate(ds, c.args) > } js> test('ABC', 'DEF') false js> test('BOY', 'BOY') true js> // match is case-insensitive js> test('boy', 'BOY') && test('BOY', 'boy') true js> // regular expressions js> test('boy', 'b.y') true js> test('buoys', 'b.*s') true
public static final Predicate AND
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr and (Expr true) (Expr true) (Expr false))'); (Expr and (Expr true) (Expr true) (Expr false)) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) false js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr and (Expr true) (Expr true) (Expr true))'); (Expr and (Expr true) (Expr true) (Expr true)) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true js> // short-circuits js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr and (Expr false) (Expr bogus))'); (Expr and (Expr false) (Expr bogus)) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) false
public static final Predicate OR
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr or (Expr false) (Expr false) (Expr false))'); (Expr or (Expr false) (Expr false) (Expr false)) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) false js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr or (Expr false) (Expr false) (Expr true))'); (Expr or (Expr false) (Expr false) (Expr true)) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true js> // short-circuits js> c = net.cscott.sdr.calls.ast.AstNode.valueOf('(Expr or (Expr true) (Expr bogus))'); (Expr or (Expr true) (Expr bogus)) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true
public static final Predicate PROGRAM_AT_LEAST
js> ds = new DanceState(new DanceProgram(Program.PLUS), Formation.SQUARED_SET); undefined; js> c = net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr PROGRAM AT LEAST 'BASIC)"); (Expr PROGRAM AT LEAST 'BASIC) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true js> c = net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr PROGRAM AT LEAST 'A2)"); (Expr PROGRAM AT LEAST 'A2) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) false
public static final Predicate TBONED
js> importPackage(net.cscott.sdr.util); // for Fraction js> FormationList = FormationList.js(this); undefined; js> SD = StandardDancer; undefined js> // rotate the formation 1/2 just to get rid of the original tags js> f = FormationList.RH_OCEAN_WAVE; f.toStringDiagram() ^ v ^ v js> d = [d for (d in Iterator(f.sortedDancers()))]; undefined js> f = f.move(d[1], f.location(d[1]).turn > (Fraction.ONE_QUARTER, false)) ; f.toStringDiagram() ^ < ^ v js> f = f.move(d[3], f.location(d[3]).turn > (Fraction.ONE_QUARTER, false)) ; f.toStringDiagram() ^ < ^ < js> // label those dancers js> f= f.mapStd([SD.COUPLE_1_BOY, SD.COUPLE_1_GIRL, > SD.COUPLE_3_BOY, SD.COUPLE_3_GIRL]); f.toStringDiagram() 1B^ 1G< 3B^ 3G< js> ds = new DanceState(new DanceProgram(Program.PLUS), f); undefined; js> function test(sel) { > let c = net.cscott.sdr.calls.ast.AstNode.valueOf( > "(Expr TBONED '"+sel+")"); > return PredicateList.valueOf(c.atom).evaluate(ds, c.args) > } js> test('BOY') false js> test('GIRL') false js> test('CENTER') true js> test('END') true js> test('HEAD') true
public static final Predicate ARE
public static final Predicate ALL
public static final Predicate EQUAL_CALL
public static final Predicate FORMATION
Matcher
).
js> ds = new DanceState(new DanceProgram(Program.PLUS), Formation.SQUARED_SET); undefined; js> c = net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr FORMATION 'STATIC SQUARE)"); (Expr FORMATION 'STATIC SQUARE) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true js> c = net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr FORMATION 'COUPLE)"); (Expr FORMATION 'COUPLE) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) true js> c = net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr FORMATION 'RH MINIWAVE)"); (Expr FORMATION 'RH MINIWAVE) js> PredicateList.valueOf(c.atom).evaluate(ds, c.args) false
Constructor Detail |
---|
public PredicateList()
Method Detail |
---|
public static Predicate valueOf(String s)
Predicate
function with the given (case-insensitive)
name.
IllegalArgumentException
- if no predicate with the given name is
found.
|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |