[toronto-lisp] Pattern Matching in CL

David Penton djp at arqux.com
Fri Nov 26 18:11:42 UTC 2010


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 -






More information about the toronto-lisp mailing list