# [plt-scheme] Is there a set data-type?

Does something like this sounds interesting and generalizable for infinite
sets?
Mixing hashes on finite sets for speed and recurrence for infinite sets in
the default case (trivial example):
(define h (make-hash))
(for-each (λ(n)(hash-set! h n #t))
'(0 2 4 6 8)) ; could be a lot larger of course
(define (odd? n)
(if (> n 0)
(hash-ref h n
; default case:
(λ()(odd? (- n 10))))
#f))
>* (even? 9876)
*#t
>* (even? 9877)
*#f
Or maybe that's just a well-known fact...
Laurent
On Fri, Feb 5, 2010 at 15:42, Laurent <laurent.orseau at gmail.com> wrote:
>* On Fri, Feb 5, 2010 at 15:41, Laurent <laurent.orseau at gmail.com> wrote:
*>>* On Fri, Feb 5, 2010 at 15:40, Laurent <laurent.orseau at gmail.com> wrote:
*>>>* On Fri, Feb 5, 2010 at 15:12, Matthias Felleisen <matthias at ccs.neu.edu>
*wrote:
>>>>*
*>>>>* On Feb 5, 2010, at 8:29 AM, Todd O'Bryan wrote:
*>>>>*
*>>>>>* What do people use for a set data-type? If there isn't one built-in,
*>>>>>* we're going to use a hash-table with #t as all the values.
*>>>>*
*>>>>* Just a tease: how would you use hashtable to represent infinite sets?
*>>>*
*>>>* From the top of my head, though that does probably not fit to the
*>>>* definition of an infinite set:
*>>>*
*>>>* (define towards-infinity-and-beyond (make-hash))
*>>>* (hash-set! towards-infinity-and-beyond 'zero '())
*>>>* (hash-set! 'me towards-infinity-and-beyond)
*>>*
*>>* oops, please read on the last line:
*>>* (hash-set! towards-infinity-and-beyond) 'me towards-infinity-and-beyond)
*>*
*>* rahhh, well you got the idea... (and I'm going to get some sleep)
*>*
*-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100205/c59384da/attachment.html>