Skip to content

Instantly share code, notes, and snippets.

@humberto-ortiz
Created August 4, 2014 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save humberto-ortiz/b4847059099e58a1273f to your computer and use it in GitHub Desktop.
Save humberto-ortiz/b4847059099e58a1273f to your computer and use it in GitHub Desktop.
;;;; All you need to know about lisp in one screen
;;;; Humberto Ortiz-Zuazaga <humberto.ortiz@upr.edu>
;;; The identity function takes one argument and returns it
(defun id (x) x)
;;; You can apply it to anything
(id 23.45) ; numbers
(id 'foo) ; symbols
(id "bar") ; strings
(id '(This is a list.)) ; lists
;;; Lisp is mostly parens function arguments parens => value
(+ 3 5)
;;; Nested however you want
(* (+ 1 4) (- 7 4))
;; even functions can be values
#'id
;; functions can be arguments (and be returned)
(id #'id)
;; and you can call functions returned as values
(funcall (id #'id) (* 3 4))
;;; The simple syntax and power of functions lets you do anything.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment