0

I'm following the suggestion here to set up racket as the default geiser/scheme. In Dr Racket I can set the first lines of code:

#lang sicp
(#%require sicp-pict)

In order to match code presented in SICP. But my source code block will not execute if I do.

#+BEGIN_SRC scheme 
;;#lang sicp
;;(#%require sicp-pict)
(define (big a b c)
           (cond ((>= a b) (if (>= b c) (+ (* a a) (* b b)) (+ (* a a) (* c c))))
                 ((>= b a) (if (>= a c) (+ (* b b) (* a a)) (+ (* b b) (* c c))))
                 ((>= c b) (+ (* c c) (* a a)))))
(big 1 2 3)
(big 3 2 1)
(big 2 2 2)
(big 1 3 2)
(big 3 1 2)
   #+END_SRC

If I comment these out, it will evaluate. I believe it will change racket behavior for later questions in SICP however. Any way to set this is org-mode?

UPDATE: I tried using emacs-ob-racket and using "racket" directly in the source code block. I get

I get the following output:

#+RESULTS:
#+begin_example
/tmp/babel-2725Aeq/org-babel-2725Rdu.rkt:3:15: read-syntax: `#lang` not enabled
  context...:
   read-lang29
   read-one/not-eof
   loop
   [repeats 2 more times]
   read-unwrapped-sequence17
   read-undotted
   read-one/not-eof
   loop
   [repeats 1 more time]
   read-unwrapped-sequence17
   read-undotted
   read-syntax
   /usr/share/racket/collects/syntax/module-reader.rkt:186:17: body
   /usr/share/racket/collects/syntax/module-reader.rkt:183:2: wrap-internal
   /usr/share/racket/collects/racket/../syntax/module-reader.rkt:65:9: lang:read-syntax
   read-syntax
   ...
#+end_example

UPDATE 2: found someone with a workaround: https://stackoverflow.com/questions/21008623/setting-language-with-lang-in-the-repl

    #lang sicp
;;C-c C-a loads #lang module into REPL (save before loading)
;;C-u C-c C-z is faster than C-c C-a
;;https://docs.racket-lang.org/sicp-manual/index.html
;;https://stackoverflow.com/questions/21008623/setting-language-with-lang-in-the-repl
(#%require sicp-pict)
(paint einstein)

However, in a source code block in org-mode, I can't get this working or displaying results in the same file. The best I can do is get results to the REPL buffer.

Now I'm looking for a way to maybe just launch racket with #lang sicp as default, like attaching a starting argument when racket is called, racket -I sicp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.