Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shakna-israel/4f8344af36d2ef9f938b54d209cc1345 to your computer and use it in GitHub Desktop.
Save shakna-israel/4f8344af36d2ef9f938b54d209cc1345 to your computer and use it in GitHub Desktop.
(define-syntax constexpr
(syntax-rules ()
((_ expr)
(begin
(syntax->datum
(datum->syntax
(quote-syntax here)
(eval 'expr (interaction-environment))))))))
(define (factorial n)
(if (<= n 1)
1
(* n (factorial (- n 1)))))
(define n
(constexpr (factorial 10)))
@shakna-israel
Copy link
Author

(define-syntax define-curried
    (syntax-rules ()
      ((_ (f . a) body ...)
       (define f (curry (lambda a (begin body ...)))))))

(define-curried (add a b)
  (+ a b))

((add 1) 2)

@shakna-israel
Copy link
Author

(define-syntax-rule (delay) 
    (lambda ( )  expr))

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