Skip to content

Lisp Syntax

Vishal Patil edited this page May 30, 2022 · 11 revisions

Syntax

Variables

(define x 1)
(define y 1.0)
(define city "Chapel Hill")

If Expression

(if (> x 10) 1 2)
(if (!= x y) (sqr x) (cube y))

Lambda Expression

(define sqr (lambda (x) (* x x)))
(sqr 20)

(define area-of-circle 
   (lambda (r) (* pi (sqr r))))

(area-of-cirle 10.0)
Clone this wiki locally