LISP Functions



Define your own functions in LISP

    (defun function_name ()
        lisp_expression1
        lisp_expression2
        ...
    )


Example

    (defun test_function ()
        (setq a 2.0)
        (setq b 3.0)
        (setq c '(This is a list))
        (princ "Square of variable a: ")
        (princ (* a a))
        (princ "\n")
        (princ "Cube of variable b: ")
        (princ (* b b b))
        (princ "\n")
        (princ "Value of variable c: ")
        (princ c)
        (princ "\n")
        (setq d "this is a string!")
        (princ d)
        (princ)
    )
    
    
    
    (test_function)

This website has been archived and is no longer maintained.