sdr 0.7

net.cscott.sdr.calls.transform
Class Fractional

java.lang.Object
  extended by net.cscott.sdr.calls.transform.TransformVisitor<T>
      extended by net.cscott.sdr.calls.transform.PartsVisitor<Fraction>
          extended by 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

Constructor Summary
Fractional(DanceState ds)
           
 
Method Summary
 SeqCall visit(Apply apply, Fraction f)
           
 Comp visit(If iff, Fraction f)
           
 In visit(In in, Fraction f)
           
 Part visit(Part p, Fraction f)
           
 Prim visit(Prim p, Fraction f)
           
 Comp visit(Seq s, Fraction f)
           
 
Methods inherited from class net.cscott.sdr.calls.transform.PartsVisitor
desugarAnd
 
Methods inherited from class net.cscott.sdr.calls.transform.TransformVisitor
visit, visit, visit, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Fractional

public Fractional(DanceState ds)
Method Detail

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>

sdr 0.7

Copyright © 2006-2009 C. Scott Ananian