define-match-spread-out
define*
7.7

define-match-spread-out

source code: https://github.com/AlexKnauth/define-match-spread-out

This file provides the define* form, which allows function definitions to be spread out across a file.

syntax

(define* (f-id args) body ...)

 
args = arg-pat ...
  | . rest-id
  | arg-pat ... . rest-id
A version of define that allows definitions to be spread across a file. Each arg-pat can be an arbitrary match pattern, and if the given argument values don’t match the patterns in the first form in the file, it tries matching them against the patterns in second form, and so on.

The patterns of all of the define* forms in the file so far are collected into a single match*-case-lambda form.

>

 

(require define-match-spread-out)

>

 

(define* (f #t) 2)

>

 

(f #t)

2

>

 

(define* (f #f) 3)

>

 

(f #t)

2

>

 

(f #f)

3

>

 

(define* (f _) 0)

>

 

(f #t)

2

>

 

(f "non-boolean stuff")

0

>

 

(define* (f x y) x)

>

 

(f #t)

2

>

 

(f "two" "arguments")

"two"