Skip to content

Instantly share code, notes, and snippets.

@cellularmitosis
Last active May 7, 2022
Embed
What would you like to do?
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