scala/comp2.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 25 Feb 2013 15:12:48 +0000
changeset 195 f06aa4e1c25b
child 205 c7975ab7c52e
permissions -rw-r--r--
tuned
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
195
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
package object comp2 {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
//  Recusive function to Abacus translation
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
import lib._
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
import abacus._
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
import recs._
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
def arity(f: Rec) = f match {
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
  case Z => 1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
  case S => 1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
  case Id(n, _) => n
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
  case Cn(n, _, _) => n
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
  case Pr(n, _, _) => n
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
  case Mn(n, _) => n 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19