Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,12 @@
|
|||
(define (eval-with-x prog x)
|
||||
(eval prog (environment-new (list (list 'x x)))))
|
||||
|
||||
(define prog '( + 1 (* x x)))
|
||||
|
||||
(eval-with-x prog 10) → 101
|
||||
(eval-with-x prog 1000) → 1000001
|
||||
(- (eval-with-x prog 1000) (eval-with-x prog 10)) → 999900
|
||||
|
||||
;; check x is unbound (no global)
|
||||
x
|
||||
😖️ error: #|user| : unbound variable : x
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
expression = "return pow(x,2) - 7"
|
||||
one = evalwithx(expression, 1.2)
|
||||
two = evalwithx(expression, 3.4)
|
||||
see "one = " + one + nl + "two = " + two + nl
|
||||
|
||||
func evalwithx expr, x
|
||||
return eval(expr)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
func eval_with_x(code, x, y) {
|
||||
var f = eval(code);
|
||||
x = y;
|
||||
eval(code) - f;
|
||||
}
|
||||
|
||||
say eval_with_x(x: 3, y: 5, code: '2 ** x'); # => 24
|
||||
Loading…
Add table
Add a link
Reference in a new issue