Scala REPL with UACalc objects

  1. Download Scala from this page.
  2. Install Scala.
    Follow the instructions given on the download page. For Ubuntu users, you will download a file called something like scala-2.10.3.tgz. Unpack this file and put a link to the scala/bin directory in your path. For example, do something like the following:

    cd ~/opt/scala  # where you downloaded scala-2.10.3
    tar xvzf scala-2.10.3.tgz
    echo "export PATH=$HOME/opt/scala/scala-2.10.3/bin:$PATH" >> ~/.bash_profile
    source ~/.bash_profile
    
  3. Download uacalc.jar.
    Either point your browser to http://uacalc.org/uacalc.jar OR do

    wget http://uacalc.org/uacalc.jar
    
  4. Start the Scala REPL with UACalc dependencies.
    In the directory where uacalc.jar is located do `scala -classpath uacalc.jar`.

    williamdemeo@kap:~/UACalc/UACalc_CLI/Jars$ scala -classpath uacalc.jar
    
    Welcome to Scala version 2.10.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25).
    Type in expressions to have them evaluated.
    Type :help for more information.
    
    scala>
    
  5. Import UACalc classes and make some objects.
    scala> import org.uacalc.alg.conlat.BasicPartition
    import org.uacalc.alg.conlat.BasicPartition
    
    scala> val a = new BasicPartition("|0,1|2,3|")
    a: org.uacalc.alg.conlat.BasicPartition = |0,1|2,3|
    
    scala> a
    res2: org.uacalc.alg.conlat.BasicPartition = |0,1|2,3|
    
    scala> val b = new BasicPartition("|0|1,2|3|")
    b: org.uacalc.alg.conlat.BasicPartition = |0|1,2|3|
    
    scala> a.compose(b)
    blocks: [[0,1],[2,3]]
    res3: org.uacalc.alg.conlat.BinaryRelation = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]]
    
  6. Post a comment in the box below!
    …and tell us about your experience with Scala and UACalc.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s