Last active
September 19, 2021 14:19
-
-
Save craigjperry2/7fb3814fd63f1ab5d63d8726a9fcbbb4 to your computer and use it in GitHub Desktop.
Progress through the on lisp book
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sync notes & files as i work through learning lisp via various books. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*~ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Book: https://sep.yimg.com/ty/cdn/paulgraham/onlisp.pdf | |
;; lisp (sbcl) install instructions | |
;; brew install sbcl | |
;; Install quicklist package manager | |
;; curl -o /tmp/ql.lisp http://beta.quicklisp.org/quicklisp.lisp | |
;; sbcl --no-sysinit --no-userinit --load /tmp/ql.lisp --eval '(quicklisp-quickstart:install :path "~/.quicklisp")' --eval '(ql:add-to-init-file)' --quit | |
;; spacemacs install instructions: | |
;; brew tap d12frosted/emacs-plus | |
;; brew install emacs-plus@27 --with-spacemacs-icon | |
;; brew link emacs-plus | |
;; brew install font-source-code-pro | |
;; git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d | |
;; configure ~/.spacemacs per my dotfiles repo | |
;; Spacemacs common lisp layer docs: https://develop.spacemacs.org/layers/+lang/common-lisp/README.html | |
;; SPC f e d - edit ~/.spacemacs | |
;; SPC f e R - reload ~/.spacemacs | |
;; chapter 1 notes | |
;; SPC m s i - launch slime repl | |
;; SPC m e c - eval current form | |
(mapcar #'+ | |
(do* ((x 1 (1+ x)) | |
(result (list x) (push x result))) | |
((= x 10) (nreverse result)))) | |
(let ((a 1) | |
(b 10)) | |
(do ((x a (+ 1 x))) | |
((> x b)) | |
(print x))) | |
;; see page 154 for how to implement (for (x a b) (print x)) | |
;; chapter 2 | |
(defun my-double (x) (* x 2)) | |
(my-double 1) | |
(eq #'my-double (car (list #'my-double))) | |
;; sharp-quote allows us to get the actual function object | |
#'(lambda (x) (* x 2)) | |
;; A lambda expression is itself also a name of a function so can be used like one | |
((lambda (x) (* x 2)) 3) | |
;; in CL we can have a function named double and a variable named double at the same time | |
(setq my-double 2) | |
(my-double my-double) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment