PasteRack.org
Paste # 1214
2014-04-06 11:50:24

Forked from paste # 1848.

Fork as a new paste.

Paste viewed 481 times.


Embed:

  1. #lang plai
  2.  
  3.  
  4. (test (calc (parse '3)) 3)
  5. (test (calc (parse '(4 + 2))) 6)
  6. (test (calc (parse '(4 / 2))) 2)
  7. (test (calc (parse '(4 * 2))) 8)
  8. (test (calc (parse '(with (x 5) (x + (with (y 3) x))))) 10)
  9. (test (calc (parse '(with (x 5) (with (y x) y)))) 5)
  10. (test (calc (parse '(with (x 5) (with (x x) x)))) 5)

=>

(exception (calc (parse (quote 3))) "calc: undefined;\n cannot reference an identifier before its definition\n  in module: 'm" '<no-expected-value> "at line 2")

(exception (calc (parse (quote (4 + 2)))) "calc: undefined;\n cannot reference an identifier before its definition\n  in module: 'm" '<no-expected-value> "at line 3")

(exception (calc (parse (quote (4 / 2)))) "calc: undefined;\n cannot reference an identifier before its definition\n  in module: 'm" '<no-expected-value> "at line 4")

(exception (calc (parse (quote (4 * 2)))) "calc: undefined;\n cannot reference an identifier before its definition\n  in module: 'm" '<no-expected-value> "at line 5")

(exception (calc (parse (quote (with (x 5) (x + (with (y 3) x)))))) "calc: undefined;\n cannot reference an identifier before its definition\n  in module: 'm" '<no-expected-value> "at line 6")

(exception (calc (parse (quote (with (x 5) (with (y x) y))))) "calc: undefined;\n cannot reference an identifier before its definition\n  in module: 'm" '<no-expected-value> "at line 7")

(exception (calc (parse (quote (with (x 5) (with (x x) x))))) "calc: undefined;\n cannot reference an identifier before its definition\n  in module: 'm" '<no-expected-value> "at line 8")