Re: Pattern matching Vs destructuring?

2017-01-27 Thread Francis Avila
There are two different concerns in what people refer to as "pattern matching": binding and flow-control. Destructuring only addresses binding. Pattern matching emphasizes flow control, and some binding features typically come along for free with whatever syntax it uses. (But you

Re: Pattern matching Vs destructuring?

2017-01-26 Thread 'Alan Forrester' via Clojure
On 27 Jan 2017, at 07:04, Didier wrote: > Some languages have pattern matching, and Clojure is said to not have it > (without a library), but it does have destructuring. > > It seems to me that destructuring is the same as pattern matching, except > that it can only be used

Pattern matching Vs destructuring?

2017-01-26 Thread Didier
Some languages have pattern matching, and Clojure is said to not have it (without a library), but it does have destructuring. It seems to me that destructuring is the same as pattern matching, except that it can only be used inside function arguments, where as pattern matching can also be used

Re: Pattern matching on lists

2016-04-08 Thread Andy-
That's described here: https://github.com/clojure/core.match/wiki/Basic-usage#sequential-types Use: [([1] :seq)] On Friday, April 8, 2016 at 2:37:37 PM UTC+2, Russell Wallace wrote: > > How do you do pattern matching on lists in Clojure? I've tried using > core.match but th

Pattern matching on lists

2016-04-08 Thread Russell Wallace
How do you do pattern matching on lists in Clojure? I've tried using core.match but the examples all deal with vectors, and trying to specify a list in the apparently obvious ways gets an error message about invalid list syntax. -- You received this message because you are subscribed t

Re: conditional logic implemented as pattern-matching and restructuring in the signature of the function

2016-02-13 Thread Brian Marick
To add to the list, I wrote `defpatterned` for /Functional Programming for the Object-Oriented Programmer/. https://github.com/marick/patterned There are probably many others. Moving pattern matching closer to `clojure.core` might be a good thing for a roadmap. I'm pretty excited by pa

conditional logic implemented as pattern-matching and restructuring in the signature of the function

2016-02-11 Thread Colin Taylor
Defm does this too though I've never got round to fully finishing it. (defm file-or-string-fn [] ([File] (println "It's a file")) ([s :- String] (println "It's a string " s)) (["magic"] (println "It's magic")) ([_] (println "It's a " (type _1 -- You received this message because you

conditional logic implemented as pattern-matching and restructuring in the signature of the function

2016-02-10 Thread Daniel
Check out defun. I believe it does exactly what you want. Admittedly I'm not aware of its current state. https://github.com/killme2008/defun -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com

conditional logic implemented as pattern-matching and restructuring in the signature of the function

2016-02-10 Thread Gary Verhaegen
It's not pattern matching, but would replacing the apply with a reduce achieve the same result? I'm not in a position to test this right now, but I believe (reduce f init ()) returns init without invoking f, and (conj x a b c) is equivalent to (reduce conj x [a b c]), so replacing

Re: conditional logic implemented as pattern-matching and restructuring in the signature of the function

2016-02-08 Thread Stuart Sierra
Clojure's destructuring is not the same thing as the "pattern matching" found in some other functional languages. Pattern matching can do various conditional checks, destructuring cannot. Clojure's "defn" supports destructuring in the argument list. Full pa

conditional logic implemented as pattern-matching and restructuring in the signature of the function

2016-02-08 Thread Laws
Sean Johnson has a great video about pattern matching, where he suggests that any function that starts with a conditional should have the conditional removed and the conditional logic implemented as pattern-matching and restructuring in the signature of the function. But after some

Re: Just found out about Elixirs function argument pattern matching...

2015-09-08 Thread Thomas Heller
> > > For instance, which one of these to you consider to be the best > representation of a event to set the expiry time: > >[:cache/expire #inst "2015-09-08T12:00:00Z"] > >{:type :cache/expire, :value #inst "2015-09-08T12:00:00Z"} > >#cache.Expire [#inst "2015-09-08T12:00:00Z"] > >

Re: Just found out about Elixirs function argument pattern matching...

2015-09-08 Thread James Reeves
On 8 September 2015 at 11:38, Thomas Heller wrote: > > If you look at these implementations > > (def OneOff [(s/one s/Str 'name) (s/one s/Str 'email)]) > > (s/defrecord OneOff > [name :- s/Str > email :- s/Str]) > > (defrecord OneOff [name email]) > > All of them do more or less the same

Re: Just found out about Elixirs function argument pattern matching...

2015-09-08 Thread Thomas Heller
I don't use schema/core.typed much in my actual projects, while I have done many attempts it just never worked out. I like the idea and should definitely use them more but it is just too much of a moving system and not stable enough yet (eg. didn't even know s/either is deprecated). If you look at

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread dennis zhuang
Thanks for your benchmark. I will upgrade all the dependencies and release 0.2.0 We are using defun with instparse in a DSL implementation, the performance is acceptable, but the code is much more readable. 2015-09-06 4:33 GMT+08:00 Rob Lally : > Out of interest, I ran the benchmarks as is,

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread Amith George
>> I probably wouldn't use protocols since I doubt there is a function signature that is exactly identical for all branches. Each branch probably needs access to different parts of your system (eg. database) and always passing everything to everything is not ideal. >> Multi-Method is great if y

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread James Reeves
On 7 September 2015 at 15:49, Timothy Baldridge wrote: > > Types are good even in dynamic languages, we should use the more. As > mentioned by Thomas, records are the idiomatic way to store typed > information in Clojure. > I don't think that's true. Or rather, I think it depends on what you mean

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread Thomas Heller
> > > (def Recipient >> (s/either PlaceHolder >> Existing >> OneOff)) >> > > This looks interesting. Where would I actually use this? I mean, if I have > created three records, I may as well implement multi methods or protocols, > right? Even if I don't do those, I will

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread Timothy Baldridge
>> Should be expressed as: >> (swap! :atom a, :function inc) One of Rich's talks on simplicity actually addresses that. He states that the above method (with keyword arguments) is actually simpler, but that this isn't exactly easy to program. And yes, I would take this same position about positio

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread Amith George
> > Looking at the "(defn register [...])" example. Where is the problem with > the first solution? It doesn't have the bugs the other implementations have > and is extremely simple to reason about? The other two solutions do the > exact same thing just slower with absolutely no gain. If you ne

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread James Reeves
On 7 September 2015 at 13:59, James Reeves wrote: > On 6 September 2015 at 15:38, Timothy Baldridge > wrote: >> >> As far as performance goes, this is normally the sort of thing that gets >> baked into an app at a pretty low level, that's why I suggest it should be >> as fast as possible. If you

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread James Reeves
On 6 September 2015 at 09:57, Amith George wrote: > > Could you elaborate on what you mean by variants being like a key value > pair? > I mean that tags are usually used to describe what the data *is*, whereas keys are usually used to describe what the data is for. For instance, one might have a

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread James Reeves
On 6 September 2015 at 15:38, Timothy Baldridge wrote: > >> I'm not sure why you think that it "complicates the code, and makes it > harder to understand". > > Alright, I'll use the phrase: using vectors as variants complects order > with data. If you hand me a vector that says [:name "tim"] I ha

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread Thomas Heller
FWIW before I came to Clojure I did a lot of Erlang and in the beginning I was at the exact same spot wanting to use pattern matching everywhere because it is so damn cool. Same goes for tagged literals. After a little while I realized that it is just not the way to do it in Clojure and

Re: Just found out about Elixirs function argument pattern matching...

2015-09-06 Thread Amith George
lue hashmap. If core.match was able to easily pattern match over a record as well as easily destructure the values in the value hashmap, we would use it. From what I have seen of core.match, it is nowhere near as easy/clean as pattern matching a vector. >> As far as performance goes, this is nor

Re: Just found out about Elixirs function argument pattern matching...

2015-09-06 Thread Timothy Baldridge
>> I'm not sure why you think that it "complicates the code, and makes it harder to understand". Alright, I'll use the phrase: using vectors as variants complects order with data. If you hand me a vector that says [:name "tim"] I have to know that "the first thing in this vector is the name of the

Re: Just found out about Elixirs function argument pattern matching...

2015-09-06 Thread James Reeves
On 6 September 2015 at 14:41, Timothy Baldridge wrote: > >> "Variants fulfil the same purpose as key/value pairs in a map. The key > denotes a context-sensitive purpose for the data, rather than its type." > > Then use a key/value type. That's my problem with this approach, it > abuses a collecti

Re: Just found out about Elixirs function argument pattern matching...

2015-09-06 Thread Timothy Baldridge
>> "Variants fulfil the same purpose as key/value pairs in a map. The key denotes a context-sensitive purpose for the data, rather than its type." Then use a key/value type. That's my problem with this approach, it abuses a collection type and therefore creates confusion as to the type of data is

Re: Just found out about Elixirs function argument pattern matching...

2015-09-06 Thread Amith George
TIL that "tagged literals" have an existing meaning in clojure. In my mind, the terms "tagged vector" and "tagged literal" were interchangeable. From a quick Google search there doesn't seem to be an existing meaning for "tagged vector". I think we can agree that it a representation of variants

Re: Just found out about Elixirs function argument pattern matching...

2015-09-06 Thread James Reeves
On 6 September 2015 at 02:31, Timothy Baldridge wrote: > >> Thanks, it helps to know using a tagged vector is a real pattern :) > > I don't know that it's a "real pattern". If I saw code like this in > production I would probably raise quite a stink about it during code > reviews. It's a cute hac

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
s/notify mailer email activate-subject activate-text) (register [:ok {:res (auth/authenticate email)}])) (= status :ok) (response/ok (:res args)) (= status :err) (response/bad-request {:errors [{:message (:res args )}]})))) With no pattern matching I had to wrap the actual arg

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
ould return an union type Result, with cases Success and Error. And it gels very nicely with pattern matching. In that light, I can acknowledge tagged vectors as a real pattern. Creating records for all these cases wouldn't be worth it in my opinion. Infact one would usually just retu

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Timothy Baldridge
>> Thanks, it helps to know using a tagged vector is a real pattern :) I don't know that it's a "real pattern". If I saw code like this in production I would probably raise quite a stink about it during code reviews. It's a cute hack, but it is also an abuse of a data structure. Now when I see [:f

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
> > * Elixir and the BEAM VM are awesome at many things, but I suspect (from > experience not evidence) that the defun version is still faster than the > elixir version. In Clojure, the defun version is not the default or idiomatic way to write functions. I kind of expected it to be slower. M

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
Thanks, it helps to know using a tagged vector is a real pattern :) Gives the confidence to explore this further for my own code. On Saturday, 5 September 2015 22:37:33 UTC+5:30, Gary Verhaegen wrote: > > It won't really help for the library/ecosystem problem, but for your own > code I'd recomm

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Rob Lally
Out of interest, I ran the benchmarks as is, and got more or less the same results - 15x. Then I tried upgrading the defun dependencies - clojure, core.match and tools.macro - all of which have newer versions, and then running the benchmarks without leiningen’s jvm-opts and in a trampolined repl

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Gary Verhaegen
It won't really help for the library/ecosystem problem, but for your own code I'd recommend watching Jeanine Atkinson's Conj talk from last year: http://m.youtube.com/watch?v=ZQkIWWTygio On Saturday, 5 September 2015, Amith George wrote: > Nice. Hadn't heard of it before. It looks interesting.

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
Nice. Hadn't heard of it before. It looks interesting. The criterium benchmark is kinda disappointing though. The pattern matched function took nearly 15x the time of the normal function. Performance aside, in Elixir, there seems to be an established convention for creating the function argumen

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread James Reeves
You might want to take a look at defun: https://github.com/killme2008/defun - James On 5 September 2015 at 09:24, Amith George wrote: > Hi, > > I just read a blog post [1] talking about Elixir pattern matching. I was > thoroughly impressed with the way its handled in Elixir. I am

Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
Hi, I just read a blog post [1] talking about Elixir pattern matching. I was thoroughly impressed with the way its handled in Elixir. I am posting this here cuz I got rather excited and wanted to discuss this with you all. My experience with pattern matching is limited to the basics of F# and

Pattern matching and web security

2014-04-18 Thread kurofune
find that half of their pitch was on the basis of security and they attributed a lot of their success in that area to pattern matching: Using Scala's built-in pattern matching, we match an incoming request, > extract the third part of the path and get the User that corresponds to >

Re: Redefining the notion of S-EXP, and pattern matching S-EXPs in clojure

2014-01-20 Thread Alan Moore
. >> >> Back in the day when lisps had only parenthesized collection types, there >> were lisp libraries >> (whose names I've long since forgotten) that would allow pattern matching >> of s-expressions, >> so that you could describe a pattern, match it to so

Re: Redefining the notion of S-EXP, and pattern matching S-EXPs in clojure

2014-01-20 Thread Alex Miller
certain capability in clojure > libraries. > > Back in the day when lisps had only parenthesized collection types, there > were lisp libraries > (whose names I've long since forgotten) that would allow pattern matching > of s-expressions, > so that you could describe a

Re: Redefining the notion of S-EXP, and pattern matching S-EXPs in clojure

2014-01-19 Thread Dom Kiva-Meyer
> Back in the day when lisps had only parenthesized collection types, there > were lisp libraries > (whose names I've long since forgotten) that would allow pattern matching > of s-expressions, > so that you could describe a pattern, match it to some tree, pick up &g

Re: Redefining the notion of S-EXP, and pattern matching S-EXPs in clojure

2014-01-19 Thread Jozef Wagner
s in without > trying to define what an s-expression is. > > The question came up as I was looking for a certain capability in clojure > libraries. > > Back in the day when lisps had only parenthesized collection types, there > were lisp libraries > (whose names I've long

Redefining the notion of S-EXP, and pattern matching S-EXPs in clojure

2014-01-19 Thread Dave Tenny
question came up as I was looking for a certain capability in clojure libraries. Back in the day when lisps had only parenthesized collection types, there were lisp libraries (whose names I've long since forgotten) that would allow pattern matching of s-expressions, so that you could descr

Re: pattern-matching in Closure?

2012-11-04 Thread Vladimir Tsichevski
com/clojure/core.match >>> >>> On Sun, Nov 4, 2012 at 10:09 PM, Vladimir Tsichevski >>> wrote: >>> > Hi gurus. >>> > >>> > Is it possible in Clojure to use pattern matching, like I can with >>> Bigloo >>> > sch

Re: pattern-matching in Closure?

2012-11-04 Thread Marek Šrank
; Vladimir > > On Monday, November 5, 2012 1:10:59 AM UTC+4, Moritz Ulrich wrote: >> >> Use core.match: https://github.com/clojure/core.match >> >> On Sun, Nov 4, 2012 at 10:09 PM, Vladimir Tsichevski >> wrote: >> > Hi gurus. >> > >

Re: pattern-matching in Closure?

2012-11-04 Thread Vladimir Tsichevski
PM, Vladimir Tsichevski > > wrote: > > Hi gurus. > > > > Is it possible in Clojure to use pattern matching, like I can with > Bigloo > > scheme, for example: > > > > (match-case '(a b a) > > ((?x ?x) 'foo) > > ((?x ?-

Re: pattern-matching in Closure?

2012-11-04 Thread Moritz Ulrich
Use core.match: https://github.com/clojure/core.match On Sun, Nov 4, 2012 at 10:09 PM, Vladimir Tsichevski wrote: > Hi gurus. > > Is it possible in Clojure to use pattern matching, like I can with Bigloo > scheme, for example: > > (match-case '(a b a) > ((?x ?x)

pattern-matching in Closure?

2012-11-04 Thread Vladimir Tsichevski
Hi gurus. Is it possible in Clojure to use pattern matching, like I can with Bigloo scheme, for example: (match-case '(a b a) ((?x ?x) 'foo) ((?x ?- ?x) 'bar)) Regards, Vladimir -- You received this message because you are subscribed to the Google Groups "Clojure&quo

Re: Pattern matching for map content

2011-10-25 Thread Michael Jaaka
Thx, this is exactly what I need. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe fr

Re: Pattern matching for map content

2011-10-25 Thread Ben Smith-Mannschott
l Jaaka >> wrote: >>> Hi! >>> Pattern matching is fine for sequence or vector destruction. >>> Is is possible to destruct map and make pattern machting? >>> For example I would like to make constraint for to some query service. >>> It would be done as ma

Re: Pattern matching for map content

2011-10-25 Thread Alex Ott
it's better to use https://github.com/clojure/core.match On Tue, Oct 25, 2011 at 11:32 AM, Ben Smith-Mannschott wrote: > On Tue, Oct 25, 2011 at 11:20, Michael Jaaka > wrote: >> Hi! >> Pattern matching is fine for sequence or vector destruction. >> Is is poss

Re: Pattern matching for map content

2011-10-25 Thread Ben Smith-Mannschott
On Tue, Oct 25, 2011 at 11:20, Michael Jaaka wrote: > Hi! > Pattern matching is fine for sequence or vector destruction. > Is is possible to destruct map and make pattern machting? > For example I would like to make constraint for to some query service. > It would be done as

Pattern matching for map content

2011-10-25 Thread Michael Jaaka
Hi! Pattern matching is fine for sequence or vector destruction. Is is possible to destruct map and make pattern machting? For example I would like to make constraint for to some query service. It would be done as map for example: { :name "Tom" :surname "Jakarta" :bi

Re: pattern matching in clojure

2011-09-30 Thread David Nolen
> wrote: >> > >> > >> > >> > >> > >> > >> > >> > > Additionally to core.match there is also matchure [1] which comes with >> > > a defn-match that can be used like this: >> > >> > > (defn-

Re: pattern matching in clojure

2011-09-30 Thread Michael Jaaka
> >> > wrote: > > >> > > 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) > >> > > ([

Re: pattern matching in clojure

2011-09-30 Thread Ambrose Bonnaire-Sergeant
chr.pohlm...@googlemail.com> >> > wrote: >> > >> > >> > >> > >> > >> > >> > >> > > Additionally to core.match there is also matchure [1] which comes with >> > > a defn-match that can be used like this: >&

Re: pattern matching in clojure

2011-09-30 Thread Ambrose Bonnaire-Sergeant
Hi Michael On Fri, Sep 30, 2011 at 4:51 PM, Michael Jaaka 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 [ma

Re: pattern matching in clojure

2011-09-30 Thread Ambrose Bonnaire-Sergeant
e.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 > > >

Re: pattern matching in clojure

2011-09-30 Thread Michael Jaaka
tch 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 > &

Re: pattern matching in clojure

2011-09-30 Thread Michael Jaaka
functions fairly close to what you're used from > Haskell. > > > [1]https://github.com/dcolthorp/matchure > > > Christian > > > On Thu, Sep 29, 2011 at 12:03 PM, Michael Jaaka > > wrote: > >> Hi! > > >> Is there any way to define functi

Re: pattern matching in clojure

2011-09-29 Thread Kevin Downey
ps://github.com/dcolthorp/matchure > > Christian > > > On Thu, Sep 29, 2011 at 12:03 PM, Michael Jaaka > wrote: >> Hi! >> >> Is there any way to define function with pattern matching in function >> signature as it is in haskell? >> >> Bye! &g

Re: pattern matching in clojure

2011-09-29 Thread Baishampayan Ghose
On Thu, Sep 29, 2011 at 6:06 PM, David Nolen 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 because you are subscri

Re: pattern matching in clojure

2011-09-29 Thread David Nolen
In core.logic you do have matche, which is conceptually similar. David On Thu, Sep 29, 2011 at 8:33 AM, Baishampayan Ghose wrote: > On Thu, Sep 29, 2011 at 6:00 PM, Ambrose Bonnaire-Sergeant > wrote: > > It's part of core.match. > > clojure.core.match.core/match > > https://github.com/clojure/c

Re: pattern matching in clojure

2011-09-29 Thread Ambrose Bonnaire-Sergeant
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 wrote: > On Thu, Sep 29, 2011 at 6:00 PM, Ambrose Bonnaire-Sergeant > wrote: > > It's part of core.match. > > clojure.core.match.core/match > > https://g

Re: pattern matching in clojure

2011-09-29 Thread Baishampayan Ghose
On Thu, Sep 29, 2011 at 6:00 PM, Ambrose Bonnaire-Sergeant 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 b.ghose at gmail.com -- You r

Re: pattern matching in clojure

2011-09-29 Thread Ambrose Bonnaire-Sergeant
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 wrote: > On Thu, Sep 29, 2011 at 5:57 PM, Ambrose Bonnaire-Sergeant > wrote: > > append is missing a closing paren. > > It should wo

Re: pattern matching in clojure

2011-09-29 Thread Baishampayan Ghose
On Thu, Sep 29, 2011 at 5:57 PM, Ambrose Bonnaire-Sergeant 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 because you are subscribed t

Re: pattern matching in clojure

2011-09-29 Thread Ambrose Bonnaire-Sergeant
append is missing a closing paren. It should work. Ambrose On Thu, Sep 29, 2011 at 8:21 PM, Baishampayan Ghose wrote: > On Thu, Sep 29, 2011 at 4:16 PM, Ambrose Bonnaire-Sergeant > wrote: > > (defn append [a b] > > (match [a b] > > [[] _] b > > [[x & as] _] (append as (cons x b)))

Re: pattern matching in clojure

2011-09-29 Thread Baishampayan Ghose
On Thu, Sep 29, 2011 at 4:16 PM, Ambrose Bonnaire-Sergeant 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 false)) Does the

Re: pattern matching in clojure

2011-09-29 Thread David Nolen
hure > > Christian > > > On Thu, Sep 29, 2011 at 12:03 PM, Michael Jaaka > wrote: > > Hi! > > > > Is there any way to define function with pattern matching in function > > signature as it is in haskell? > > > > Bye! > > > > -- &

Re: pattern matching in clojure

2011-09-29 Thread David Nolen
https://github.com/clojure/core.match > > Thanks, > Ambrose > > On Thu, Sep 29, 2011 at 6:03 PM, Michael Jaaka < > michael.ja...@googlemail.com> wrote: > >> Hi! >> >> Is there any way to define function with pattern matching in function >> sig

Re: pattern matching in clojure

2011-09-29 Thread Christian Pohlmann
. [1] https://github.com/dcolthorp/matchure Christian On Thu, Sep 29, 2011 at 12:03 PM, Michael Jaaka wrote: > Hi! > > Is there any way to define function with pattern matching in function > signature as it is in haskell? > > Bye! > > -- > You received this message b

Re: pattern matching in clojure

2011-09-29 Thread Ambrose Bonnaire-Sergeant
ore.match Thanks, Ambrose On Thu, Sep 29, 2011 at 6:03 PM, Michael Jaaka wrote: > Hi! > > Is there any way to define function with pattern matching in function > signature as it is in haskell? > > Bye! > > -- > You received this message because you are subscribed to

pattern matching in clojure

2011-09-29 Thread Michael Jaaka
Hi! Is there any way to define function with pattern matching in function signature as it is in haskell? Bye! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that post

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-23 Thread Brent Millare
Millare wrote: > > > > > > > > > > > > For pattern matching code size is a one time cost. For predicate > > dispatch, > > > that's a lot of code to generated, since every new predicate case will > > > produce an entirely new tree. But perhaps people won&#x

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-22 Thread David Nolen
On Mon, Aug 22, 2011 at 3:07 PM, Brent Millare wrote: > > For pattern matching code size is a one time cost. For predicate > dispatch, > > that's a lot of code to generated, since every new predicate case will > > produce an entirely new tree. But perhaps people wo

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-22 Thread Brent Millare
Actually to simply further, instead of wrapping the old DAG tree, it simply replaces the DAG tree with the compilation step. The compilation step then makes the new DAG tree and calls it. On Aug 22, 3:07 pm, Brent Millare wrote: > > For pattern matching code size is a one time cos

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-22 Thread Brent Millare
> For pattern matching code size is a one time cost. For predicate dispatch, > that's a lot of code to generated, since every new predicate case will > produce an entirely new tree. But perhaps people won't care that much. Only > time and experience reports will tell. If you

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-22 Thread Brent Millare
rate. > Fortunately Maranget did some measurements with real world patterns - code > size for decision trees built with good heuristics were never more than > 1.5-2X the size of their backtracking counterparts. > > For pattern matching code size is a one time cost. For predicate dispa

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-21 Thread David Nolen
ode size for decision trees built with good heuristics were never more than 1.5-2X the size of their backtracking counterparts. For pattern matching code size is a one time cost. For predicate dispatch, that's a lot of code to generated, since every new predicate case will produce an entirely

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-21 Thread Brent Millare
I have a question about the presentation. You mention that you can't achieve the same dispatching performance in the open case compared to the closed space. Lets ignore the namespace issue (maybe by restricting ourselves to only one namespace). Also lets assume the predicate ordering is solved.

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-20 Thread Timothy Washington
Excellent talk David. This is hitting a programming sweet spot that I've wanted for a while. I haven't tried prolog, standard ml, haskell, etc. But jquery was the first tool that clued me into a kind of pattern matching and predicate dispatch: $( ".classA .classB#containingId

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-19 Thread David Nolen
On Fri, Aug 19, 2011 at 3:57 AM, Ken Wesson wrote: > On Thu, Aug 18, 2011 at 11:00 PM, Meikel Brandmeyer wrote: > > Eh, what exactly does slideshare provide over a PDF put on some server > somewhere? > > Apparently, the ability to annoy the hell out of whoever you try to > share it with. You c

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-19 Thread Sam Aaron
Awesome talk - thanks! I particularly enjoyed the sign behind you that says "Don't Panic!" - it helped keep me calm during the hairily complex parts :-) I really look forward to seeing where you go with this stuff… Sam --- http://sam.aaron.name On 18 Aug 2011, at 21:10, David Nolen wrote: >

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-19 Thread Ken Wesson
On Thu, Aug 18, 2011 at 11:00 PM, Meikel Brandmeyer wrote: > Eh, what exactly does slideshare provide over a PDF put on some server > somewhere? Apparently, the ability to annoy the hell out of whoever you try to share it with. -- Protege: What is this seething mass of parentheses?! Master: Yo

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-18 Thread Meikel Brandmeyer
Hi, Am 18.08.2011 um 22:27 schrieb Laurent PETIT: > 2011/8/18 David Nolen > SlideShare link, http://www.slideshare.net/DavidNolen/patterns-8907600 > > Arrrgh, and now slideshare wants me to authenticate via FB or a slideshare > account if I want to download the slides, again. > > Ok, I've alr

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-18 Thread Laurent PETIT
2011/8/18 David Nolen > SlideShare link, http://www.slideshare.net/DavidNolen/patterns-8907600 Arrrgh, and now slideshare wants me to authenticate via FB or a slideshare account if I want to download the slides, again. Ok, I've already got a slideshare account, so I'll try to remember the pass

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-18 Thread Laurent PETIT
2011/8/18 Baishampayan Ghose > > I don't have a Facebook account (and don't want to create one), neither > have > > or want to create a scribd account. Could it be possible to have the > slides > > available for download without having to authenticate (e.g. slideshare) ? > > Slides are on Scribd

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-18 Thread Laurent PETIT
Thanks David, I can't wait reading them ! Cheers, -- Laurent 2011/8/18 David Nolen > SlideShare link, http://www.slideshare.net/DavidNolen/patterns-8907600 > > David > > > On Thu, Aug 18, 2011 at 2:57 PM, Laurent PETIT wrote: > >> Hello, >> >> I don't have a Facebook account (and don't want t

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-18 Thread David Nolen
SlideShare link, http://www.slideshare.net/DavidNolen/patterns-8907600 David On Thu, Aug 18, 2011 at 2:57 PM, Laurent PETIT wrote: > Hello, > > I don't have a Facebook account (and don't want to create one), neither > have or want to create a scribd account. Could it be possible to have the > sl

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-18 Thread Baishampayan Ghose
> I don't have a Facebook account (and don't want to create one), neither have > or want to create a scribd account. Could it be possible to have the slides > available for download without having to authenticate (e.g. slideshare) ? Slides are on Scribd as well - http://www.scribd.com/doc/62571669

Re: Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-18 Thread Laurent PETIT
Hello, I don't have a Facebook account (and don't want to create one), neither have or want to create a scribd account. Could it be possible to have the slides available for download without having to authenticate (e.g. slideshare) ? 2011/8/18 David Nolen > In case you didn't see this elsewhere

Video & Slides on Pattern Matching and Predicate Dispatch in Clojure

2011-08-18 Thread David Nolen
In case you didn't see this elsewhere: http://vimeo.com/27860102 David -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient w

Protocol Power - Pattern Matching Java Classes

2011-08-11 Thread David Nolen
I realized that supporting pattern matching on Java classes is pretty trivial - 15 lines code needed to be changed. I think this a good example of how powerful protocol really are: https://gist.github.com/1141252 David -- You received this message because you are subscribed to the Google

Re: ANN: Optimized Pattern Matching Library for Clojure

2011-08-10 Thread Ambrose Bonnaire-Sergeant
Hi James, On Wed, Aug 10, 2011 at 5:43 PM, James Sofra wrote: > > Just to clarify, you can extend the matching to new types but the match is > 'closed' in the sense that unlike mutimethods you can't add additional > cases? Is that correct? > > For the 0.1 release, that is correct. In future rele

Re: ANN: Optimized Pattern Matching Library for Clojure

2011-08-10 Thread James Sofra
Hi David, Looks really neat! Just to clarify, you can extend the matching to new types but the match is 'closed' in the sense that unlike mutimethods you can't add additional cases? Is that correct? Hope that makes sense, James Sofra -- You received this message because you are subscribed to

Re: ANN: Optimized Pattern Matching Library for Clojure

2011-08-09 Thread Peter Taoussanis
This is great stuff: thank you! I can totally see this being the kind of thing like destructuring, where once you've used it you won't want to go back :) -- Peter -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cl

  1   2   >