|
sdr 0.6 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.cscott.sdr.calls.ExprList
public class ExprList
The ExprList contains ExprFunc definitions and the
basic machinery used to evaluate generic Exprs.
| Field Summary | |
|---|---|
static ExprFunc<Fraction> |
_ADD_NUM
Simple math: addition. |
static ExprFunc<Fraction> |
_DIVIDE_NUM
Simple math: division. |
static ExprFunc<String> |
_FACING_PATTERN
|
static ExprFunc<Fraction> |
_FLOOR
Simple math: return integer part of a fraction. |
static ExprFunc<Fraction> |
_FRACTION
Simple math: return fractional part of a number. |
static ExprFunc<String> |
_INOUT_PATTERN
Check whether dancers are facing "in" or "out" of the center of the formation. |
static ExprFunc<Fraction> |
_MOD_NUM
Simple math: modulo. |
static ExprFunc<Fraction> |
_MULTIPLY_NUM
Simple math: multiplication. |
static ExprFunc<String> |
_ROLL_PATTERN
|
static ExprFunc<String> |
_SELECTION_PATTERN
Check the order of the selected dancers within the given formation. |
static ExprFunc<Fraction> |
_SUBTRACT_NUM
Simple math: subtraction. |
static ExprFunc<String> |
_SWEEP_PATTERN
|
static ExprFunc |
LITERAL
|
static ExprFunc<Fraction> |
NUM_DANCERS
|
| Method Summary | ||
|---|---|---|
static
|
evaluate(String atom,
Class<T> type,
DanceState ds,
List<Expr> args)
This method evaluates Expr nodes. |
|
static
|
isConstant(String atom,
Class<T> type,
List<Expr> args)
This method tells whether an Expr will result in a constant. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final ExprFunc LITERAL
public static final ExprFunc<Fraction> _ADD_NUM
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> fc = java.lang.Class.forName('net.cscott.sdr.util.Fraction'); undefined js> c=net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr _add num '2 '1)") (Expr _add num '2 '1) js> c.evaluate(fc, ds).toProperString() 3
public static final ExprFunc<Fraction> _MULTIPLY_NUM
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> fc = java.lang.Class.forName('net.cscott.sdr.util.Fraction'); undefined js> c=net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr _multiply num '3 '2)") (Expr _multiply num '3 '2) js> c.evaluate(fc, ds).toProperString() 6
public static final ExprFunc<Fraction> _SUBTRACT_NUM
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> fc = java.lang.Class.forName('net.cscott.sdr.util.Fraction'); undefined js> c=net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr _subtract num '3 '2)") (Expr _subtract num '3 '2) js> c.evaluate(fc, ds).toProperString() 1
public static final ExprFunc<Fraction> _DIVIDE_NUM
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> fc = java.lang.Class.forName('net.cscott.sdr.util.Fraction'); undefined js> c=net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr _divide num '3 '2)") (Expr _divide num '3 '2) js> c.evaluate(fc, ds).toProperString() 1 1/2
public static final ExprFunc<Fraction> _MOD_NUM
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> fc = java.lang.Class.forName('net.cscott.sdr.util.Fraction'); undefined js> c=net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr _mod num '3/4 '1/2)") (Expr _mod num '3/4 '1/2) js> c.evaluate(fc, ds).toProperString() 1/4
public static final ExprFunc<Fraction> _FLOOR
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> fc = java.lang.Class.forName('net.cscott.sdr.util.Fraction'); undefined js> c=net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr _floor '3 3/4)") (Expr _floor '3 3/4) js> c.evaluate(fc, ds).toProperString() 3 js> c=net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr _floor (Expr _subtract num '0 '3 3/4))") (Expr _floor (Expr _subtract num '0 '3 3/4)) js> c.evaluate(fc, ds).toProperString() -4
public static final ExprFunc<Fraction> _FRACTION
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined; js> fc = java.lang.Class.forName('net.cscott.sdr.util.Fraction'); undefined js> c=net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr _fraction '3 3/4)") (Expr _fraction '3 3/4) js> c.evaluate(fc, ds).toProperString() 3/4 js> // note that (floor(n) + fraction(n)) = n js> c=net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr _fraction (Expr _subtract num '0 '3 3/4))") (Expr _fraction (Expr _subtract num '0 '3 3/4)) js> c.evaluate(fc, ds).toProperString() 1/4
public static final ExprFunc<Fraction> NUM_DANCERS
public static final ExprFunc<String> _ROLL_PATTERN
public static final ExprFunc<String> _SWEEP_PATTERN
public static final ExprFunc<String> _FACING_PATTERN
public static final ExprFunc<String> _INOUT_PATTERN
js> FormationList = FormationListJS.initJS(this); undefined; js> SD = StandardDancer; undefined js> e = net.cscott.sdr.calls.ast.AstNode.valueOf("(Expr _INOUT PATTERN)"); (Expr _INOUT PATTERN) js> f=FormationList.PARALLEL_RH_WAVES ; f.toStringDiagram() ^ v ^ v ^ v ^ v js> ds = new DanceState(new DanceProgram(Program.PLUS), f); undefined; js> e.evaluate(java.lang.Class.forName("java.lang.String"), ds); oioiioio js> f = FormationList.TRADE_BY; f.toStringDiagram() ^ ^ v v ^ ^ v v js> ds = new DanceState(new DanceProgram(Program.PLUS), f); undefined; js> e.evaluate(java.lang.Class.forName("java.lang.String"), ds); ooiiiioo js> f = Formation.SQUARED_SET ; f.toStringDiagram() 3Gv 3Bv 4B> 2G< 4G> 2B< 1B^ 1G^ js> ds = new DanceState(new DanceProgram(Program.PLUS), f); undefined; js> e.evaluate(java.lang.Class.forName("java.lang.String"), ds); iiiiiiii js> f = Formation.SQUARED_SET.rotate(ExactRotation.ONE_EIGHTH) ; f.toStringDiagram() 4BQ 3GL 4GQ 3BL 1B7 2G` 1G7 2B` js> ds = new DanceState(new DanceProgram(Program.PLUS), f); undefined; js> e.evaluate(java.lang.Class.forName("java.lang.String"), ds); iiiiiiii
public static final ExprFunc<String> _SELECTION_PATTERN
js> FormationList = FormationListJS.initJS(this); undefined; js> SD = StandardDancer; undefined js> f = FormationList.RH_OCEAN_WAVE; f.toStringDiagram() ^ v ^ v 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^ 1Gv 3B^ 3Gv js> ds = new DanceState(new DanceProgram(Program.PLUS), f); undefined; js> function test(sel, pat) { > let c = net.cscott.sdr.calls.ast.AstNode.valueOf( > "(Expr MATCH (Expr _SELECTION PATTERN '"+sel+") '\""+pat+"\")"); > return PredicateList.valueOf(c.atom).evaluate(ds, c.args) > } js> test('BOY', '____') false js> test('BOY', 'x_x_') true js> test('BOY', '_x_x') false js> test('CENTER', '_xx_') true js> test('HEAD', 'xxxx') true js> test('SIDE', '____') true js> test('COUPLE 1', 'xx__') true js> test('SIDE', '_xx_') false js> // wildcards js> test('BOY', 'x...') true
| Method Detail |
|---|
public static <T> T evaluate(String atom,
Class<T> type,
DanceState ds,
List<Expr> args)
throws ExprFunc.EvaluationException
Expr nodes.
ExprFunc.EvaluationException
public static <T> boolean isConstant(String atom,
Class<T> type,
List<Expr> args)
Expr will result in a constant.
|
sdr 0.6 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||