Skip to content

Instantly share code, notes, and snippets.

@greghendershott
Last active May 16, 2017 01:30
Show Gist options
  • Save greghendershott/e769d95bfc77d493992fe37ad7c7db57 to your computer and use it in GitHub Desktop.
Save greghendershott/e769d95bfc77d493992fe37ad7c7db57 to your computer and use it in GitHub Desktop.
;; A fairly simple Racket program like this:
(module m racket/base
(define (f xs)
(for/list ([x (in-list xs)])
(add1 x)))
(f '(1 2 3 4)))
;; Fully expanded with:
;;
;; (println (syntax->datum (expand (with-input-from-file "foo.rkt" read-syntax))))
;;
;; Is something like this:
;;
;; (module m racket/base
;; (#%module-begin (module configure-runtime '#%kernel (#%module-begin
;; #(#%require racket/runtime-config) (#%app configure '#f)))
;; #(define-values (f) (lambda (xs) (#%app alt-reverse (let-values
;; #(((lst) xs)) (if (#%app list? lst) (#%app void) (let-values ()
;; #(#%app in-list lst))) (#%app (letrec-values (((for-loop) (lambda
;; #(fold-var lst) (if (#%app pair? lst) (let-values (((x) (#%app
;; #unsafe-car lst))) (if '#t (let-values (((fold-var) (let-values
;; #(((fold-var) fold-var)) (let-values (((fold-var) (let-values ()
;; #(#%app cons (let-values () (#%app add1 x)) fold-var)))) (#%app
;; #values fold-var))))) (if '#t (#%app for-loop fold-var (#%app
;; #unsafe-cdr lst)) fold-var)) fold-var)) fold-var)))) for-loop) null
;; #lst))))) (#%app call-with-values (lambda () (#%app f '(1 2 3 4)))
;; #print-values)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment