Skip to content

Instantly share code, notes, and snippets.

@cellularmitosis
Last active May 7, 2022 07:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cellularmitosis/9fba12d41dace4d9f11093e148a21c50 to your computer and use it in GitHub Desktop.
Save cellularmitosis/9fba12d41dace4d9f11093e148a21c50 to your computer and use it in GitHub Desktop.
Common Lisp Notes

Common Lisp Notes

All symbols: http://www.lispworks.com/documentation/HyperSpec/Front/X_AllSym.htm

Resources

Libraries to look into

Types

  • Strings: "hello"
  • Characters: #\z
  • Numbers:
    • Bit: 0, 1
    • Integer: 42
    • Single float: 12.3, 12.3f0, 1.23e1
    • Double float: 12.3d0
    • Ratio: 1/2
    • Complex: #c(1 2) (1 + 2i)
  • Boolean:
    • nil and '() are falsy, everything else is truthy.
    • t is true.

Making bindings

Values:

  • local: let, let*
  • global: defvar, defparameter, defconstant

Mutation:

  • setq, setf

Functions:

  • local: flet, labels
  • global: defun

Aliasing a function

Aliasing evenp as even?:

(setf (fdefinition (quote even?)) (function evenp))
(setf (fdefinition 'even?) #'evenp)

let

(let list of pairs expression expression ...)

(let ((a 1)) (print a))
(let ((a 1) (b 2)) (print a) (print b))

sclr | hyperspec

let*

Use let* when you need to define variables in terms of each other.

(let ((a 1) (b a)) (print a) (print b))

hyperspec

loop

hyperspec

Advent of code 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment