On Dec 5, 2008, at 1:33 PM, Brian Doyle wrote:
> I started to play with cond-let in the contrib.cond package and got an
> unexpected error:
>
> user=> (cond-let [x (zero? 0)] (println "hello world"))
> java.lang.Exception: Unsupported binding form: (zero? 0)
> (NO_SOURCE_FILE:11)
I updated cond-let yesterday to support the new "everything that
introduces names like let does has its binding forms in a vector"
regime. However, in the case of cond-let, only the binding-form
appears inside the vector, not a value, and there should only be one
binding-form as the rest are ignored.
Here's an example with the current cond-let from svn:
------------
Contents of file cond_let_example.clj on classpath:
------------
(ns cond-let-example
(:use clojure.contrib.cond))
(def letters {"a" :vowel
"b" :consonant
"c" :consonant
"d" :consonant
"e" :vowel})
(def numbers {1 :odd
2 :even
3 :odd
4 :even
5 :odd})
(defn classify
[x]
(cond-let [type]
(letters x) type
(numbers x) (str (name type))
:else "dunno"))
------------
Repl Session
------------
Clojure
user=> (use 'cond-let-example)
nil
user=> (doseq [i ["a" "r" "t" "f" "u" "l" :blub 1 9 7 3 :life "on"
'mars]] (prn (classify i)))
:vowel
"dunno"
"dunno"
"dunno"
"dunno"
"dunno"
"dunno"
"odd"
"dunno"
"dunno"
"odd"
"dunno"
"dunno"
"dunno"
nil
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---