clojure destructuring vs haskell-like argument pattern matching
clojure, functional-programming, haskell
Solution
You can use core.match if desired
For example,
(defn foo [v]
(match v
[x] x
[x y & more] (+ (* x y) (foo more))
:else nil))
Problem
Coming from Haskell I find it hard in Clojure to traverse some data types. In Haskell if I like to do some recursion on a type, in most basic case something like ``` foo (x : []) = Just value foo (x : y : xs) = bar y (foo xs) foo _ = Nothing ``` is just fine. But I think Clojure's destructuring is nothing near of being powerful as Haskell's pattern matching. Is there a nice idiomatic way to accomplish what I'm trying to do? For an example if I have a list/vector how can I match a case when there is no more elements and such?