net.cscott.sdr.calls.transform
Class Fractional
java.lang.Object
net.cscott.sdr.calls.transform.TransformVisitor<T>
net.cscott.sdr.calls.transform.PartsVisitor<Fraction>
net.cscott.sdr.calls.transform.Fractional
public class Fractional
- extends PartsVisitor<Fraction>
Transformation implementing
BasicList._FRACTIONAL
.
This only handles the case where the fraction is less than one;
BasicList._FRACTIONAL
handles
the whole-number portions of the fraction.
- Author:
- C. Scott Ananian
- Tests:
Use Fractional class to evaluate TWICE QUARTER RIGHT:
js> importPackage(net.cscott.sdr.calls)
js> importPackage(net.cscott.sdr.calls.ast)
js> importPackage(net.cscott.sdr.util)
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined;
js> callname="dosado"
dosado
js> call = net.cscott.sdr.calls.CallDB.INSTANCE.lookup(callname)
dosado[basic]
js> comp = call.getEvaluator(null, java.util.Arrays.asList()).simpleExpansion()
(In '6 (Opt (From 'RH MINIWAVE (Seq (Part 'INDIVISIBLE '1 (Seq (Apply '_finish dosado))))) (From 'ANY (Seq (Part 'INDIVISIBLE '1 (Seq (Apply '_mixed touch))) (Part 'DIVISIBLE '3 (Seq (Apply '_finish dosado)))))))
js> comp.accept(new Fractional(ds), Fraction.ONE_QUARTER)
(In (Expr _multiply num '1/4 '6) (Opt (From 'ANY (Seq (Part 'INDIVISIBLE '1 (Seq (Apply '_mixed touch)))))))
js> try {
> comp.accept(new Fractional(ds), Fraction.ONE_THIRD)
> } catch (e) {
> print(e.javaException)
> }
net.cscott.sdr.calls.BadCallException: No formation options left: No formation options left: Primitives cannot be subdivided
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Fractional
public Fractional(DanceState ds)
visit
public Comp visit(If iff,
Fraction f)
- Overrides:
visit
in class TransformVisitor<Fraction>
visit
public In visit(In in,
Fraction f)
- Overrides:
visit
in class TransformVisitor<Fraction>
visit
public Prim visit(Prim p,
Fraction f)
- Overrides:
visit
in class TransformVisitor<Fraction>
visit
public Part visit(Part p,
Fraction f)
- Overrides:
visit
in class TransformVisitor<Fraction>
visit
public SeqCall visit(Apply apply,
Fraction f)
- Overrides:
visit
in class PartsVisitor<Fraction>
visit
public Comp visit(Seq s,
Fraction f)
- Overrides:
visit
in class TransformVisitor<Fraction>
Copyright © 2006-2009 C. Scott Ananian