repo.or.cz
/
prop.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
simple.cc - generated code example
[prop.git]
/
tools
/
demos
/
calculus.pcc
blob
d90c8b85cb884365944919e5136d49af7e67e2f1
1
#include "calculus.ph"
2
3
4
Term simplify(Term t)
5
{ match (t) {
6
case (Int(i) + Int(j)): Int(i+j)
7
case (Int(i) - Int(j)): Int(i-j)
8
case (Int(i) * Int(j)): Int(i*j)
9
case (Int(i) / Int(j)): Int(i/j)
10
case (Int(i) ^ Int(j)): Int(power(i,j))
11
case (e ^ Int(0)): Int(1)
12
case (e ^ Int(1)): e
13
case _:
14
}
15
}