addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1linklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

[SICP]: org-babel and racket

From: Tim V.
Sent on: Thursday, March 27, 2014 6:47 PM
Hey Everyone,

In case you were interested, I figured I'd give a quick write up to
the steps required to get org-babel working with Racket.

1. Follow the instructions for Emacs found at Racket's site:
http://docs.racke...­. Geiser's the only
important bit, but the rest is probably worth doing. I'm still not
convinced I have a working scribble installation. The best way to
install geiser is to use ELPA with the marmalade repo.

2. Customize the geiser-implementatio­n group so that the Geiser Active
Implementations is set to the single symbol: racket.

3. Customize group org-babel setting:

    1. Org babel load languages: Insert choice Scheme
    2. Org Babel Scheme Cmd: racket -f

4. Customize group org-babel-tangle inserting scheme/rkt as a cons
cell into Org Babel Tangle Lang Exts.

After that, an org file with a `#+BEGIN_SRC scheme` block in them
should do the right thing when you `C-c '` and `C-c C-c`.

The other neat thing I figured out is that if you name a session like

    #+BEGIN_SRC scheme :session "1.6"

You can then use the persistent session between code blocks. For me
that looked like:

* Exercise 1.6

  Alyssa P. Hacker doesn’t see why if needs to be provided as a special
  form. “Why can’t I just define it as an ordinary procedure in terms of
  cond?” she asks. Alyssa’s friend Eva Lu Ator claims this can indeed be
  done, and she defines a new version of if:

  #+BEGIN_SRC scheme :session "1.6"
    (define (new-if predicate then-clause else-clause)
      (cond (predicate then-clause)
            (else else-clause)))

  Eva demonstrates the program for Alyssa:

  #+BEGIN_SRC scheme :session "1.6"
    (new-if (= 2 3) 0 5)                    ; 5

    (new-if (= 1 1) 0 5)                    ; 0

  Delighted, Alyssa uses new-if to rewrite the square-root program:

  #+BEGIN_SRC scheme :session "1.6"
    (define (sqrt-iter guess x)
      (new-if (good-enough? guess x)
              (sqrt-iter (improve guess x)

  What happens when Alyssa attempts to use this to compute square
  roots? Explain.

Even though those source blocks are separated, they can all reference
each other's state.

Anyway, just a quick write up. Hope that helps someone else till we
get the full monty from Paul. :)


In Christ,

Timmy V.

http://five.sente...­ -- Spend less time on mail

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy