Skip to content

Instantly share code, notes, and snippets.

Created Nov 20, 2011
What would you like to do?
Pattern-matching defintion
#lang racket
(require syntax/parse/define)
(define-simple-macro (def (f0:id p0 ...) rhs0:expr (~seq (f:id p ...) rhs:expr) ...)
(define f0 (match-lambda** [(p0 ...) rhs0] [(p ...) rhs] ...)))
(def (fact 0) 1 (fact 1) 1 (fact n) (* n (fact (- n 1))))
(fact 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment