Skip to content

Instantly share code, notes, and snippets.

@cellularmitosis
Last active January 15, 2022 20:06
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/9dbb85c4834fad4f2455d569a2dd466e to your computer and use it in GitHub Desktop.
Save cellularmitosis/9dbb85c4834fad4f2455d569a2dd466e to your computer and use it in GitHub Desktop.
Scratchpad: 100 days of Common Lisp

Scratchpad: 100 days of Common Lisp

I'd like to organize a "100 days of Common Lisp" (inspired by 100 days of Swift).

I'll use this as a scratch space to collect resources and organize my thoughts.

TODO:

  • atoms: numbers, strings
  • symbols, binding using setq
  • list evaluation, (+ 1 1) etc
  • quote
  • declaring functions, lambda
  • lists
  • vectors
  • alists
  • hash tables

resources to use:

Day X: Install CLISP

On a Mac, install Homebrew and then use Homebrew to install CLISP.

  • Open a terminal
  • Run bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Run brew install clisp
  • Run clisp
    • Hit CTRL+d (or type (quit) at the REPL prompt) to exit CLISP.

Day X: CLISP REPL, part 1

When you run clisp, it starts a REPL (read-eval-print loop), where you can type in Common Lisp code and have it executed.

Try typing in (+ 1 1), which should evaluate to 2:

[1]> (+ 1 1)
2

Try typing in foo:

[2]> foo

*** - SYSTEM::READ-EVAL-PRINT: variable FOO has no value
The following restarts are available:
USE-VALUE      :R1      Input a value to be used instead of FOO.
STORE-VALUE    :R2      Input a new value for FOO.
ABORT          :R3      Abort main loop
Break 1 [3]> 

Here we see a condition bring thrown (called exceptions in other languages), which starts the debugger.

You can always exit the debugger by hitting CTRL+d.

Day X: Atom + SLIMA

Download the Atom editor.

Install the SLIMA package.

Set up (or memorize) key bindings for compiling and evaluating forms.

Day X: HyperSpec

The HyperSpec describes the 1994 ANSI standardization of Common Lisp (which is the most recent version of Common Lisp).

The list of all symbols is very useful.

Day X: Simplified Common Lisp Reference

See https://jtra.cz/stuff/lisp/sclr/index.html

Day X: ashok-khanna/lisp-notes

See https://github.com/ashok-khanna/lisp-notes

Day X: CSCI 330 lisp examples

See http://csci.viu.ca/~wesselsd/courses/csci330/code/lisp/

Day X: Common Lisp Cookbook

See https://lispcookbook.github.io/cl-cookbook/

Day X: 40ants/lisp-project-of-the-day

See https://github.com/40ants/lisp-project-of-the-day

Day X: common-lisp-libraries.readthedocs.io

See:

Day X: UltraSpec

See https://phoe.tymoon.eu/clus/doku.php?id=articles:manifesto

Day X: quicklisp

Quicklisp is the defacto package manager for Common Lisp.

Day X: Quickdocs

Quickdocs is a documentation portal for quicklisp packages.

Day X: Quicklisp blog

Xach publishes a Quicklisp news blog which highlights newly added projects. Check it out and consider subscribing to stay on top of new libraries.

Day X: asdf

See https://common-lisp.net/project/asdf/

Day X: roswell

See https://roswell.github.io/Home.html

Day X: The most popular Quicklisp projects

Occaisionally, Xach publishes a blog post with quicklisp project download stats, which you can use to figure out which quicklisp libraries are most commonly used. http://blog.quicklisp.org/2018/03/download-stats-for-february-2018.html

See also https://github.com/phoe/quicklisp-stats

See also https://www.quicklisp.org/stats/2021/2021-12.csv

Day X: alexandria

See https://common-lisp.net/project/alexandria/draft/alexandria.html

Day X: lisp-lang.org

See https://lisp-lang.org/learn/

Day X: Practical Common Lisp

See https://gigamonkeys.com/book/

Day X: Exercism

See - https://exercism.org/tracks/common-lisp

Day X: bordeaux-threads

See https://common-lisp.net/project/bordeaux-threads/

Day X: Rainer Joswig

See:

Day X: Common Lisp standards

See https://stackoverflow.com/questions/33848241/most-recent-standard-of-common-lisp

Day X: Advent of Code solutions

Day X: Neil Munro tutorial videos

See https://www.youtube.com/c/NeilMunro/videos

Day X: equality

eq, eql, equal, equalp, =, char=, char-equal, string=, string-equal

  • = only works on numbers, will match ints and floats
  • eq is t for same, identical objects
  • eql is eq + numbers (same type) + characters
  • equal is eql + deep list comparison,
  • equalp also arrays, structures, hash tables, but is case insensitive?!?

Day X: set, setq

  • (set 'a 1)
  • (setq a 1)
  • (setf (symbol-value 'a) 1)
  • (boundp 'a), (makunbound 'a)

note: set doesn't work with lexical variables, but setq does.

Day X: value cells

  • symbol-value
  • (setf (symbol-value 'a) 1)

Day X: ANSI Common Lisp, ch 2.1

Day X: ANSI Common Lisp, ch 2.2

Day X: ANSI Common Lisp, ch 2.3

Day X: ANSI Common Lisp, ch 2.4

Day X: ANSI Common Lisp, ch 2.5

Day X: ANSI Common Lisp, ch 2.6

Day X: ANSI Common Lisp, ch 2.7

Day X: ANSI Common Lisp, ch 2.8

Day X: ANSI Common Lisp, ch 2.9

Day X: ANSI Common Lisp, ch 2.10

Day X: ANSI Common Lisp, ch 2.11

Day X: ANSI Common Lisp, ch 2.12

Day X: ANSI Common Lisp, ch 2.13

Day X: ANSI Common Lisp, ch 2.14

Day X: ANSI Common Lisp, ch 2.15

Day X: ANSI Common Lisp, ch 2.16

Day X: Aliasing a function

Aliasing evenp as even?:

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

a.k.a.

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

See https://gist.github.com/cellularmitosis/e2d6362375e536d8d1e154e3b73c86c3

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