Created
August 9, 2019 23:04
-
-
Save ruliana/e8f8181fda6d8866be632a0fd09b219f to your computer and use it in GitHub Desktop.
Fighting scheme macros
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
(define empty? null?) | |
(define empty '()) | |
(define first car) | |
(define rest cdr) | |
(define (split2 item lst) | |
(let loop ([remaining lst] | |
[left empty]) | |
(cond [(empty? remaining) (values (reverse left) empty)] | |
[(equal? item (first remaining)) (values (reverse left) (rest remaining))] | |
[else (loop (rest remaining) (cons (first remaining) left))]))) | |
(define (reverse-thing stx) | |
stx) | |
(define-syntax (power-let stx) | |
(syntax-case stx () | |
[(_ body0 body* ...) | |
(with-syntax ([new-body (reverse-thing #'body0)]) | |
#'(let [new-body] body* ...))])) | |
;(power-let (1 a) (printf "~s\n" a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment