Skip to content

Instantly share code, notes, and snippets.

@Glorp
Created August 28, 2017 21:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Glorp/739af1fa8793d944cbd35355fc81427c to your computer and use it in GitHub Desktop.
Save Glorp/739af1fa8793d944cbd35355fc81427c to your computer and use it in GitHub Desktop.
#lang racket
(provide (rename-out [my-read read]
[my-read-syntax read-syntax]))
(define (my-read in) (syntax->datum (my-read-syntax #f in)))
(define (rev stx)
(define l (syntax->list stx))
(if l
(datum->syntax stx (reverse (map rev l)) stx stx)
stx))
(define (my-read-syntax src in)
(define blah #'e)
(define res
(let loop ()
(define stx (read-syntax src in))
(cond [(eof-object? stx) '()]
[else
(set! blah stx)
(cons (rev stx) (loop))])))
(datum->syntax blah
`(module merp racket
,@res)
blah
blah))
#lang reader "baklengs.rkt"
((x x +)
(x double) define)
((3 2 1 list) double map)
@Glorp
Copy link
Author

Glorp commented Aug 28, 2017

Put both files in same dir, e.g. by downloading zip and unzipping somewhere. Run test.rkt with Racket. Should get the list '(2 4 6).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment