Thanks for feedback. But now I'm came across a problem. I'm studying
Learn You a Haskell for Great Good! and I'm on chapter Functionally
Solving Problems reading Reverse Polish notation calculator.
I wanted to write it in Clojure. So instead of: http://pastebin.com/QzhbyD6d
I wrote:
Btw. I'm using [match 0.2.0-SNAPSHOT] and Clojure 1.3 but this
import instruction
(use '[match.core :only [match]])
from official website of match library doesn't work, only (use
'[clojure.core.match.core :only [match ] ]) works
and I have given a try to matchure and IT WORKS ;-)
But why do I
There's a problem with destructuring lists (seems like a bug).
If stack is always a vector, it works.
(defn rpn' [ stack symb ]
(match [stack symb]
[ [x y z ] * ] (apply vector (* x y ) z)
[ [x y z ] + ] (apply vector (+ x y ) z)
[ x sum ] [ (reduce + x) ]
Hi Michael
On Fri, Sep 30, 2011 at 4:51 PM, Michael Jaaka michael.ja...@googlemail.com
wrote:
Btw. I'm using [match 0.2.0-SNAPSHOT] and Clojure 1.3 but this
import instruction
(use '[match.core :only [match]])
from official website of match library doesn't work, only (use
I've opened an issue concerning this bug:
http://dev.clojure.org/jira/browse/MATCH-21
Ambrose
On Fri, Sep 30, 2011 at 5:04 PM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
There's a problem with destructuring lists (seems like a bug).
If stack is always a vector, it works.
Thanks!
On Sep 30, 11:33 am, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
I've opened an issue concerning this bug:
http://dev.clojure.org/jira/browse/MATCH-21
Ambrose
On Fri, Sep 30, 2011 at 5:04 PM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
This probably won't get fixed unless someone does a really good job of
convincing me otherwise. Vector notation is reserved for things which
support random access.
(defn rpn' [ stack symb ]
(match [stack symb]
[([x y z] :seq) * ] (apply vector (* x y ) z)
[([x y z] :seq) + ]
Hi,
core.match might be what you're looking for.
(defn append [a b]
(match [a b]
[[] _] b
[[x as] _] (append as (cons x b)))
(defn or [b1 b2]
(match [b1 b2]
[true _] true
[_ true] true
:else false))
https://github.com/clojure/core.match
Additionally to core.match there is also matchure [1] which comes with
a defn-match that can be used like this:
(defn-match choose
([_ 0] 1)
([0 _] 0)
([?n ?k] (+ (choose (dec n) (dec k)) (choose (dec n) k
This makes defining functions fairly close to what you're used from Haskell.
And if you'd actually like a little bit of sugar so that it's really at the
level of the function definition - patch welcome! :)
David
On Thu, Sep 29, 2011 at 6:46 AM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
Hi,
core.match might be what you're looking for.
(defn
matchure does some funny things to deal with code size, including generating
internals fns which will break recur. core.match avoided this problem until
quite recently. We've now added backtracking to control code size for
certain kinds of pattern matches. However this also conflicts w/ recur,
On Thu, Sep 29, 2011 at 4:16 PM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
(defn append [a b]
(match [a b]
[[] _] b
[[x as] _] (append as (cons x b)))
(defn or [b1 b2]
(match [b1 b2]
[true _] true
[_ true] true
:else
append is missing a closing paren.
It should work.
Ambrose
On Thu, Sep 29, 2011 at 8:21 PM, Baishampayan Ghose b.gh...@gmail.comwrote:
On Thu, Sep 29, 2011 at 4:16 PM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
(defn append [a b]
(match [a b]
[[] _] b
On Thu, Sep 29, 2011 at 5:57 PM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
append is missing a closing paren.
It should work.
Where does `match` come from? I couldn't find it anywhere.
Regards,
BG
--
Baishampayan Ghose
b.ghose at gmail.com
--
You received this message
It's part of core.match.
clojure.core.match.core/match
https://github.com/clojure/core.match
Thanks,
Ambrose
On Thu, Sep 29, 2011 at 8:28 PM, Baishampayan Ghose b.gh...@gmail.comwrote:
On Thu, Sep 29, 2011 at 5:57 PM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
append is
On Thu, Sep 29, 2011 at 6:00 PM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
It's part of core.match.
clojure.core.match.core/match
https://github.com/clojure/core.match
Sorry Ambrose, I was so stupid, I was looking at core.logic :-)
Regards,
BG
--
Baishampayan Ghose
In this exchange I've written core.logic when I meant core.match about 4
times xD
Ambrose
On Thu, Sep 29, 2011 at 8:33 PM, Baishampayan Ghose b.gh...@gmail.comwrote:
On Thu, Sep 29, 2011 at 6:00 PM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
It's part of core.match.
In core.logic you do have matche, which is conceptually similar.
David
On Thu, Sep 29, 2011 at 8:33 AM, Baishampayan Ghose b.gh...@gmail.comwrote:
On Thu, Sep 29, 2011 at 6:00 PM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
It's part of core.match.
On Thu, Sep 29, 2011 at 6:06 PM, David Nolen dnolen.li...@gmail.com wrote:
In core.logic you do have matche, which is conceptually similar.
Right, I knew about `matche` and that added to all the confusion.
Regards,
BG
--
Baishampayan Ghose
b.ghose at gmail.com
--
You received this message
Last I checked matchjure generates fns which break recur (there is an issue
open for it). Trading recursion for matching seems like a bad deal, I
recommend using match instead.
On Sep 29, 2011 4:32 AM, Christian Pohlmann chr.pohlm...@googlemail.com
wrote:
Additionally to core.match there is also
20 matches
Mail list logo