source: project/wiki/eggref/3/generalised-case @ 13621

Last change on this file since 13621 was 13621, checked in by sjamaan, 11 years ago

Move old chicken 3 eggs over to eggref/3

File size: 2.9 KB
Line 
1[[tags: egg]]
2
3== generalised-case
4
5[[toc:]]
6
7=== Description
8
9A generalised version of {{case}}.  This {{case*}} accepts an
10equality predicate (the built-in {{case}} uses {{eqv?}}) and
11evaluates its cases instead of implicitly quoting them.
12
13=== Author
14
15[[Peter Bex]]
16
17=== Requirements
18
19None
20
21=== Download
22
23[[http://www.call-with-current-continuation.org/eggs/generalised-case.egg|generalised-case.egg]]
24
25=== Documentation
26
27Generalised-case works like
28[[http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-7.html#%_idx_114|R5RS case]],
29except that it accepts an extra argument after the key and the
30data in the clauses are evaluated.  The special form has the name
31{{case*}}.
32
33The extra argument is the equality predicate which is used to
34determine equality of members.  The {{key}} is passed as the first
35parameter, the datum to match is passed as the second parameter.
36
37=== Example
38
39<examples><example>
40<init>(use generalised-case)</init>
41<expr>
42(define (foo-maker) "FOO")
43
44(case* "foo" string-ci=?
45  (("bar" (foo-maker) "qux") (display "bar, foo or qux\n") 1)
46  (else (display "We got something else\n") 2))
47</expr>
48<result>1</result>
49<output>bar, foo or qux</output>
50</example></examples>
51
52=== Changelog
53
54* 1.3 Fix in define-macro version by Reed Sheridan
55* 1.2 Fix in macro by Peter Bex
56* 1.1 Apply some optimisations [Thanks to Christian Jaeger]
57* 1.0 Initial release
58
59=== License
60
61  Copyright (c) 2005, Peter Bex
62  All rights reserved.
63 
64  Redistribution and use in source and binary forms, with or without
65  modification, are permitted provided that the following conditions are
66  met:
67 
68  Redistributions of source code must retain the above copyright
69  notice, this list of conditions and the following disclaimer.
70 
71  Redistributions in binary form must reproduce the above copyright
72  notice, this list of conditions and the following disclaimer in the
73  documentation and/or other materials provided with the distribution.
74 
75  Neither the name of the author nor the names of its contributors may
76  be used to endorse or promote products derived from this software
77  without specific prior written permission.
78 
79  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
80  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
81  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
82  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
83  COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
84  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
85  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
86  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
87  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
88  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
89  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
90  OF THE POSSIBILITY OF SUCH DAMAGE.
Note: See TracBrowser for help on using the repository browser.