And try to get some of the svg-tags working as I would like.
5.3 KiB
Programming in Scheme for SICP
A literate programming file configuring Emacs.
Introduction
First, install MIT-Scheme, the Lisp dialect used throughout the SICP book:
brew install mit-scheme
or sudo apt install mit-scheme
.
brew install mit-scheme
Or better yet, let’s use Guile:
brew install guile
Geiser (Scheme Interface)
The geiser project attempts to be the interface between Emacs and various Schemes. Since I can’t decide which to use, I’ll install/configure them all.
(use-package geiser
:init
(setq geiser-mit-binary "/usr/local/bin/scheme"
geiser-racket-binary "/usr/local/bin/racket"
geiser-guile-binary "/usr/local/bin/guile"
geiser-active-implementations '(guile)
geiser-default-implementations '(guile))
:config
(use-package geiser-mit)
(use-package geiser-guile)
(use-package geiser-racket)
(add-to-list 'org-babel-load-languages '(scheme . t)))
Do we need a Scheme work for Org Babel? According to this document, we just need to make sure we add the :session
variable to start the REPL.
Try it Out
This should work?
message
However, it doesn’t output the results back into this buffer. What is the point of connecting it to ob
?
Install SICP
Let’s get the book available as an Info page:
(use-package sicp)
And does this work?
(inc 42)
Still having difficulty getting the Scheme REPL to output the results back into this document. Let’s try Racket…
If we want to read the sicp.info file, looks like we need this, at least, temporarily:
(add-to-list 'auto-mode-alist '("\\.info\\'" . Info-mode))
Racket
Actually, let’s do this with Racket:
brew install racket
While Racket, as a Scheme, should work with Geiser (below), let’s also get racket-mode working:
(use-package racket-mode
:config (setq racket-program "/usr/local/bin/racket"))
Can we get Racket working with Org?
(use-package ob-racket
:straight (:type git :protocol ssh :host github :repo "DEADB17/ob-racket")
:after org
:config
(add-to-list 'org-babel-load-languages '(racket . t)))
Try It Out
Working for values?
(* 6 7)
42
Working for output?
(define str-1 "hello")
(define str-2 "world")
(define all (string-join (list str-1 str-2) ", "))
(display (string-titlecase all))
Hello, World
The interface is horrendously slow, as the :session
doesn’t seem to work, and starting up a Racket REPL takes a long time.
SICP and Racket
If using Racket for SICP, install the SICP language:
raco pkg install --auto --update-deps sicp
We now can give it a #lang sicp
(or better yet, use the :lang
header) to define certain SICP-specify features:
Let’s try this now:
(inc 42)
43