[plt-scheme] generic programming in plt scheme

From: Skeptic . (skeptic2000 at hotmail.com)
Date: Sun Apr 25 02:24:40 EDT 2010

Ok, sequences are interesting, I have probably never heard of them because they are PLT-specific.
However, length was more an example than a specific case I need to dealt with.
Thanks anyway!

> Date: Sat, 24 Apr 2010 23:18:46 -0700
> Subject: Re: [plt-scheme] generic programming in plt scheme
> From: mark.engelberg at gmail.com
> To: skeptic2000 at hotmail.com
> CC: plt-scheme at list.cs.brown.edu
> In my experience, PLT Scheme is not generally written in a way that
> makes it easy to define generic operations over multiple datatypes,
> however, in this case you're in luck.  You can use the sequence
> abstraction:
> (define (generic-length l)
>   (for/fold ([len 0]) ([element l]) (add1 len)))
> Works on lists, vectors, strings, and user-defined streams (that
> implement the sequence abstraction).
> See sequence in the help desk for more info.
> On Sat, Apr 24, 2010 at 11:05 PM, Skeptic . <skeptic2000 at hotmail.com> wrote:
> >
> > Hi,
> > What would be the idiomatic way of defining a generic length procedure over,
> > let's say lists, vectors, strings and user-defined streams, in PLT Scheme ?
> > Thanks.
> >
Obtenez la version mobile de Messenger ici
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100425/c95d9be9/attachment.html>

Posted on the users mailing list.