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