exporting example code from slideshow documents

27 views
Skip to first unread message

David Bremner

unread,
Feb 21, 2021, 9:05:42 AM2/21/21
to Racket Users

I mostly use emacs org-mode documents for making (latex beamer) slide
decks. This allows me to "tangle" the example code from the slides,
along with whatever needed supporting material, to generate example
programs that I can share with students. Is there a (pre-built?) way to
do something similar with a #lang slideshow document? I guess in
principle I could embed my slideshow program in an org-mode document,
but I wondered if this could be accomplished with racket, and with less
levels of compiling.

d

Robby Findler

unread,
Feb 21, 2021, 11:14:35 AM2/21/21
to David Bremner, Racket Users
I often end up writing macros that both quote some code and expand into that code where the first one is usually via `racket` or one of the code-rendering libraries, and the second one gets used to write tests for the code in my slideshow. These tend to be short and fairly ad hoc macros because I end up customizing them in various ways to support the presentation. I haven't found an idea for a nice general purpose library that does this. In the meantime, there's a bare bones example below. I usually end up starting like that but then doing various fancy things to support the specific examples in good ways.

hth,
Robby

#lang racket
(require slideshow
         slideshow/code
         syntax/parse/define)
(module+ test (require rackunit))

(define-simple-macro
  (code+run e)
  (values (code e) e))

(define-values (x^2+1-pict x^2+1-func)
  (code+run
   (λ (x)
     (+ (* x x)
        1))))
(module+ test
  (check-equal? (x^2+1-func 0) 1)
  (check-equal? (x^2+1-func -1) 2))

(slide x^2+1-pict)



--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/87o8gdplce.fsf%40tethera.net.
Reply all
Reply to author
Forward
0 new messages