diff options
author | def <dennis@felsin9.de> | 2015-03-17 17:50:32 +0100 |
---|---|---|
committer | def <dennis@felsin9.de> | 2015-03-17 17:50:32 +0100 |
commit | fd4e6299057b0ce59a89553e7c32a9ea62da14db (patch) | |
tree | 45bb61ec52b415ffd07caae7c5b7fc10a0d99577 /tests/showoff | |
parent | 8e651fa0d456786df15445e10e14b9d4e96c21ff (diff) | |
download | Nim-fd4e6299057b0ce59a89553e7c32a9ea62da14db.tar.gz |
Rename PNimrodNode to NimNode
Diffstat (limited to 'tests/showoff')
-rw-r--r-- | tests/showoff/tdrdobbs_examples.nim | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/showoff/tdrdobbs_examples.nim b/tests/showoff/tdrdobbs_examples.nim index 13a685950..78f711325 100644 --- a/tests/showoff/tdrdobbs_examples.nim +++ b/tests/showoff/tdrdobbs_examples.nim @@ -13,7 +13,7 @@ var g = 70 ++g g ++ 7 g.`++`(10, 20) -echo g +echo g #let lv = stdin.readline @@ -56,7 +56,7 @@ type fkLit, ## element is a literal like 0.1 fkAdd, ## element is an addition operation fkMul, ## element is a multiplication operation - fkExp ## element is an exponentiation operation + fkExp ## element is an exponentiation operation type Formula = ref object @@ -78,16 +78,16 @@ proc evaluate(n: Formula, varToVal: proc (name: string): float): float = echo evaluate(Formula(kind: fkLit, value: 0.4), nil) proc isPolyTerm(n: Formula): bool = - n.kind == fkMul and n.left.kind == fkLit and (let e = n.right; + n.kind == fkMul and n.left.kind == fkLit and (let e = n.right; e.kind == fkExp and e.left.kind == fkVar and e.right.kind == fkLit) proc isPolynomial(n: Formula): bool = - isPolyTerm(n) or + isPolyTerm(n) or (n.kind == fkAdd and isPolynomial(n.left) and isPolynomial(n.right)) let myFormula = Formula(kind: fkMul, left: Formula(kind: fkLit, value: 2.0), - right: Formula(kind: fkExp, + right: Formula(kind: fkExp, left: Formula(kind: fkVar, name: "x"), right: Formula(kind: fkLit, value: 5.0))) @@ -104,7 +104,7 @@ proc pat2kind(pattern: string): FormulaKind = import macros -proc matchAgainst(n, pattern: PNimrodNode): PNimrodNode {.compileTime.} = +proc matchAgainst(n, pattern: NimNode): NimNode {.compileTime.} = template `@`(current, field: expr): expr = newDotExpr(current, newIdentNode(astToStr(field))) |