Do any of you have experience with pattern-matching packages in CL? By this I do not mean only regular expression stuff such as in CL-PPCRE, but rather pattern-matching for function definition as in Haskell, OCaml, the Racket match function, etc. (Although perhaps CL-PPCRE does this also;, but I am only familiar with the string-handling stuff in CL-PPCRE.)
My question is: If I want to mimic what is possible in Haskell, ML and kin, etc. what is the best CL stuff for pattern matching? I have looked at CL-MATCH but find the documentation a bit hard to penetrate. I am in a bit of a hurry to get something done that pattern matching would really help, so any recommendations are welcome.
Best,
- Dave -
Do any of you have experience with pattern-matching packages in CL? By this I do not mean only regular expression stuff such as in CL-PPCRE, but rather pattern-matching for function definition as in Haskell, OCaml, the Racket match function, etc. (Although perhaps CL-PPCRE does this also;, but I am only familiar with the string-handling stuff in CL-PPCRE.)
My question is: If I want to mimic what is possible in Haskell, ML and kin, etc. what is the best CL stuff for pattern matching? I have looked at CL-MATCH but find the documentation a bit hard to penetrate. I am in a bit of a hurry to get something done that pattern matching would really help, so any recommendations are welcome.
At the low end, CL has destructuring-bind as part of the CL spec.
At the high end (?) I've got paip prolog running (under LW) and could give you a copy, or the fixes.
I took a quick look at cl-match - it seems to be what you're asking for, iiuc. If it's just a syntactical / mind-set issue, you can send me a sample of what you want and we could try to suss out how to express it in cl-match via email...
pt
On 2010-11-25, at 2:51 PM, Paul Tarvydas wrote:
Do any of you have experience with pattern-matching packages in CL? By this I do not mean only regular expression stuff such as in CL-PPCRE, but rather pattern-matching for function definition as in Haskell, OCaml, the Racket match function, etc. (Although perhaps CL-PPCRE does this also;, but I am only familiar with the string-handling stuff in CL-PPCRE.)
My question is: If I want to mimic what is possible in Haskell, ML and kin, etc. what is the best CL stuff for pattern matching? I have looked at CL-MATCH but find the documentation a bit hard to penetrate. I am in a bit of a hurry to get something done that pattern matching would really help, so any recommendations are welcome.
At the low end, CL has destructuring-bind as part of the CL spec.
At the high end (?) I've got paip prolog running (under LW) and could give you a copy, or the fixes.
I took a quick look at cl-match - it seems to be what you're asking for, iiuc. If it's just a syntactical / mind-set issue, you can send me a sample of what you want and we could try to suss out how to express it in cl-match via email...
pt
Hi Paul. Thanks for getting back to me on this.
Yes, after doing a bit more reading I now think that cl-match is what I want. I shall putter my way through the documentation to learn it in due course.
However, in the meanwhile I have managed to do what I needed to do with Scheme. I am doing a course for my M.Eng. that involves many proofs by structural induction. I ended up in disagreement with someone about how three of my proofs worked. I wanted to make my point by showing running programs. Of course these programs do not themselves constitute proofs, but they served to clarify my argument quite nicely because I could output intermediate results.
The thing about pattern-matching is that it made the programs "look like" the structural induction on paper in a way that is hard to beat.
I don't mind Scheme, but I still prefer CL because it does seem to me to be "industrial strength". So, since I now have some idea how to use pattern-matching for some purposes I shall tackle cl-match before long.
I am learning both Haskell and OCaml, since these seem to be the darlings of the academics at Mac. I may learn to love them, but so far I just find them interesting rather than great. In all my born days I have never run into a language that appealed to me the way CL does.
Thanks again.
Best,
- Dave -
Mildly unrelated but at the same time relevant.
http://matt.might.net/articles/red-black-delete/
The author describes the functional red-black tree and then how to write a delete function for that tree.
What's also interesting about the article is the demonstration of racket's pattern matching. This kind of syntax would be worthwhile in any LISP.
abram
On 11/26/2010 10:11 AM, David Penton wrote:
On 2010-11-25, at 2:51 PM, Paul Tarvydas wrote:
Do any of you have experience with pattern-matching packages in CL? By this I do not mean only regular expression stuff such as in CL-PPCRE, but rather pattern-matching for function definition as in Haskell, OCaml, the Racket match function, etc. (Although perhaps CL-PPCRE does this also;, but I am only familiar with the string-handling stuff in CL-PPCRE.)
My question is: If I want to mimic what is possible in Haskell, ML and kin, etc. what is the best CL stuff for pattern matching? I have looked at CL-MATCH but find the documentation a bit hard to penetrate. I am in a bit of a hurry to get something done that pattern matching would really help, so any recommendations are welcome.
At the low end, CL has destructuring-bind as part of the CL spec.
At the high end (?) I've got paip prolog running (under LW) and could give you a copy, or the fixes.
I took a quick look at cl-match - it seems to be what you're asking for, iiuc. If it's just a syntactical / mind-set issue, you can send me a sample of what you want and we could try to suss out how to express it in cl-match via email...
pt
Hi Paul. Thanks for getting back to me on this.
Yes, after doing a bit more reading I now think that cl-match is what I want. I shall putter my way through the documentation to learn it in due course.
However, in the meanwhile I have managed to do what I needed to do with Scheme. I am doing a course for my M.Eng. that involves many proofs by structural induction. I ended up in disagreement with someone about how three of my proofs worked. I wanted to make my point by showing running programs. Of course these programs do not themselves constitute proofs, but they served to clarify my argument quite nicely because I could output intermediate results.
The thing about pattern-matching is that it made the programs "look like" the structural induction on paper in a way that is hard to beat.
I don't mind Scheme, but I still prefer CL because it does seem to me to be "industrial strength". So, since I now have some idea how to use pattern-matching for some purposes I shall tackle cl-match before long.
I am learning both Haskell and OCaml, since these seem to be the darlings of the academics at Mac. I may learn to love them, but so far I just find them interesting rather than great. In all my born days I have never run into a language that appealed to me the way CL does.
Thanks again.
Best,
- Dave -
toronto-lisp mailing list toronto-lisp@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/toronto-lisp
On 2010-11-29, at 1:18 PM, Abram Hindle wrote:
Mildly unrelated but at the same time relevant.
http://matt.might.net/articles/red-black-delete/
The author describes the functional red-black tree and then how to write a delete function for that tree.
What's also interesting about the article is the demonstration of racket's pattern matching. This kind of syntax would be worthwhile in any LISP.
abram
Thanks, Abram. I checked that link - looks interesting.
I did a bit more reading on this, and see that I have some more general things to learn, e.g. unification. As I usually do, I am procrastinating about learning either cl-match or cl-unification, since I can drop over into racket for ordinary pattern matching when I need to. I am becoming a bit more adept at Haskell and OCaml too, but more slowly than I should, I confess.
Paul's mention of Prolog tipped me off that I should go back and read Chapter 24 of Graham's On Lisp, in which a CL prolog implementation is discussed. I shall probably have time to get to grips with this stuff during xmas break, after exams are over for the term.
Give us an update on what you have been up to - on the list or off, if you prefer.
- Dave -