Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexknauth/define-match-spread-out
a racket macro that allows definitions to be spread across a file
https://github.com/alexknauth/define-match-spread-out
Last synced: about 1 month ago
JSON representation
a racket macro that allows definitions to be spread across a file
- Host: GitHub
- URL: https://github.com/alexknauth/define-match-spread-out
- Owner: AlexKnauth
- License: mit
- Created: 2015-05-21T04:37:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-01-07T14:41:55.000Z (almost 3 years ago)
- Last Synced: 2024-10-16T02:55:10.739Z (3 months ago)
- Language: Racket
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
define-match-spread-out [![Build Status](https://travis-ci.org/AlexKnauth/define-match-spread-out.png?branch=master)](https://travis-ci.org/AlexKnauth/define-match-spread-out)
===documentation: http://docs.racket-lang.org/define-match-spread-out/index.html
A racket library that allows you to write code like this:
```racket
(define* (f #t) 2)
(define* (f #f) 3)
(define* (f _) 0)
(define* (f x y) x)
```
That would be roughly equivalent to
```racket
(define f
(match*-case-lambda
[[#t] 2]
[[#f] 3]
[[_] 0]
[[x y] x]))
```
Or, using just `case-lambda` and `match` variants:
```racket
(define f
(case-lambda
[(tmp)
(match tmp
[#t 2]
[#f 3]
[_ 0])]
[(tmp1 tmp2)
(match* (tmp1 tmp2)
[(x y) x])]))
```