Contents    Page-10    Prev    Next    Page+10    Index   

Function Definition

Functions are defined using defun (define function):


   >(defun myabs (x)
      (if (>= x 0)
          x
          (- x) ) )

   >(myabs 3)
   3

   >(myabs -7)
   7

Local variables can be declared using let. Variables can be assigned values using setq (set-quote):


(defun cylinder-volume (radius height)
  (let (area)
    (setq area (* pi (expt radius 2)))
    (* area height) ) )