Created
June 14, 2021 14:57
-
-
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 :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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