X-Git-Url: https://git.piment-noir.org/?p=TD_LISP.git;a=blobdiff_plain;f=course%2Ffunctions.lsp;fp=course%2Ffunctions.lsp;h=f547702cb92173a9a2e337699b5b57c168cdd00b;hp=0000000000000000000000000000000000000000;hb=15c46339dbd746558fb5b82c2823e0ede2cc7bfd;hpb=a5273e70fe54850ee147232848c009ede063ee7b diff --git a/course/functions.lsp b/course/functions.lsp new file mode 100755 index 0000000..f547702 --- /dev/null +++ b/course/functions.lsp @@ -0,0 +1,21 @@ +#!/usr/bin/env newlisp + +; function addition +;(define (f x y) (+ x y)) +;(println (f 1 2)) + +;(define f (lambda (x y) (+ x y))) +(setq f (lambda (x y) (+ x y))) +;(set 'f (lambda (x y) (+ x y))) +(println (f 1 2)) +(println ((lambda (x y) (+ x y)) 1 2)) + +(println (let ((x 1) (y 2)) (+ x y))) +(println ((lambda (x y) (+ x y)) 1 2)) + +(setq x 3 y 4) +(println "x="x" y="y) +(println ((lambda (y) (setq x 5 y 6) (+ x y)) 1 2)) +(println "x="x" y="y) + +(exit)