API for fcase - clojure-contrib v1.2 (stable)

by Stuart Sierra

clojure-contrib is now deprecated

clojure-contrib is no longer being developed or maintained.

Rather than a single, monolithic, contributions library, Clojure now has a set of separate libraries for each unit of functionality. The libraries are in the Clojure GitHub organization at https://github.com/clojure. API documentation of the libraries can be found at https://clojure.github.io.

If you're looking for a specific function or namespace from the old clojure-contrib, see "Where Did Clojure.Contrib Go".


Full namespace name: clojure.contrib.fcase

Overview

This file defines a generic "case" macro called "fcase" which takes
the equality-testing function as an argument.  It also defines a
traditional "case" macro that tests using "=" and variants that
test for regular expressions and class membership.


Note (December 23, 2008): This library has been supplanted by the
inclusion of "condp" in clojure.core as of Clojure SVN rev. 1180.

Public Variables and Functions



case

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (case test-value & clauses)
Like cond, but test-value is compared against the value of each
test expression with =.  If they are equal, executes the "body"
expression.  Optional last expression is executed if none of the
test expressions match.
Source


fcase

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (fcase compare-fn case-value & test-expr-clauses)
Generic switch/case macro.  'fcase' is short for 'function case'.

The 'compare-fn' is a fn of two arguments.

The 'test-expr-clauses' are value-expression pairs without
surrounding parentheses, like in Clojure's 'cond'.

The 'case-value' is evaluated once and cached.  Then, 'compare-fn'
is called once for each clause, with the clause's test value as its
first argument and 'case-value' as its second argument.  If
'compare-fn' returns logical true, the clause's expression is
evaluated and returned.  If 'compare-fn' returns false/nil, we go to
the next test value.

If 'test-expr-clauses' contains an odd number of items, the last
item is the default expression evaluated if no case-value matches.
If there is no default expression and no case-value matches, fcase
returns nil.

See specific forms of this macro in 'case' and 're-case'.

The test expressions in 'fcase' are always evaluated linearly, in
order.  For a large number of case expressions it may be more
efficient to use a hash lookup.
Source


in-case

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (in-case test-value & clauses)
Like case, but test expressions are sequences.  The test expression
is true if any item in the sequence is equal (tested with '=') to
the test value.
Source


instance-case

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (instance-case test-value & clauses)
Like case, but the test expressions are Java class names, tested with
'instance?'.
Source


re-case

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (re-case test-value & clauses)
Like case, but the test expressions are regular expressions, tested
with re-find.
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.