Skip to content

Instantly share code, notes, and snippets.

@ralsei
Created June 14, 2021 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralsei/d979ec4cab20c899516ec131793da0a0 to your computer and use it in GitHub Desktop.
Save ralsei/d979ec4cab20c899516ec131793da0a0 to your computer and use it in GitHub Desktop.
I added delimeters to Racket to make it easier to find the end of a block :)
#lang racket/base
(module nightmare racket/base
(provide (rename-out [nightmare-#%app #%app]))
(require (for-syntax racket/base
racket/list
racket/match
syntax/parse))
(define-for-syntax (tser lst)
(match lst
['() '()]
[(cons _ '()) '()]
[(cons a b) (cons a (tser b))]))
(define-syntax (nightmare-#%app stx)
(syntax-parse stx
[(_ f:expr) (raise-syntax-error '%#app "no")]
[(_ f:expr e ...)
#:when (eq? (syntax->datum (last (attribute e)))
(syntax->datum (attribute f)))
#:with (v ...) (tser (attribute e))
#'(#%app f v ...)])))
(module main racket/base
(require (submod ".." nightmare))
(define (f)
(displayln "hello, world" displayln))
(f f)
(define (fib n)
(if (<= n 2 <=)
1
(+ (fib (- n 1 -) fib)
(fib (- n 2 -) fib) +)))
(fib 20 fib))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment