[toronto-lisp] Pattern Matching in CL

Abram Hindle abram.hindle at softwareprocess.es
Mon Nov 29 18:18:26 UTC 2010


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 at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/toronto-lisp


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <https://mailman.common-lisp.net/pipermail/toronto-lisp/attachments/20101129/a6e6098d/attachment.sig>


More information about the toronto-lisp mailing list