tags:

views:

301

answers:

1

I want to use the condp clause but I dont know how to catch any unmatched clause. How do I do that?

(defn subst[id value W-lang]
  (let [[type expr][(first W-lang)(rest W-lang)]]
    (condp = type
     'num (first expr)
     'add expr    
     ***** expr)))
+2  A: 

The documentation for condp says:

A single default expression can follow the clauses, and its value will be returned if no clause matches. If no default expression is provided and no clause matches, an IllegalArgumentException is thrown.

So:

(condp = type
    'num (first expr)
    'add expr
    expr)))
Greg Hewgill