[Cs254f11] Two Questions on sets and lazy infinite functions

Lee Spector lspector at hampshire.edu
Sun Oct 2 17:15:23 EDT 2011


This is an answer from Omri, but:

- Omri: it was held because you posted from a different address that the one you're subscribed with... 

- Josiah: can you give me (off list!) the list admin password, so that I can approve such postings in the future?


Begin forwarded message:
> From: Omri Bernstein <hippiccolo at gmail.com>
> Subject: Re: [Cs254f11] Two Questions on sets and lazy infinite functions
> Date: October 2, 2011 4:48:11 PM EDT
> To: "cs254f11 at lists.hampshire.edu" <cs254f11 at lists.hampshire.edu>
> 
> 
> I'm going to start with the second question because I'm not sure I understand the first one. As for finding whether something is in a given set you can use either (some #{\3} given-set) or (contains? #{\3} given-set). If \3 is in the given set, the first one (some ...) will return \3 (i.e. the value it finds). If it is not in the set, this first method will return nil. The second option will return true or false. I think for the sake of speed, Lee was suggesting we use the first option (some ...).
> 
> However if you are looking for a set within a set--like if you were looking to test whether the set #{\3} was in a given set, the syntax might need to be (some #{#{\3}} given-set) or (contains? #{#{\3}} given-set). Don't quote me on that though, because I haven't tried it.
> 
> As for your first question, I'll try to answer it, but I may not understand. For one thing, if you want an infinite lazy sequence of the natural numbers you can do (iterate inc 1). Iterate works like this: (iterate f x) returns an infinite lazy sequence of (x (f x) (f (f x)) ...). So maybe that answers your question about an infinite lazy repeat of a function that requires arguments.
> 
> Hope that helps.
> 
> -Omri
> 
> 
> On Oct 2, 2011, at 14:21, Jack Laxson <jrl11 at hampshire.edu> wrote:
> 
>> 
>> 
>> ---------- Forwarded message ----------
>> From: Jack L. <jackjrabbit at gmail.com>
>> Date: Sun, Oct 2, 2011 at 2:20 PM
>> Subject: Two Questions on sets and lazy infinite functions
>> To: cs254f11 <cs254f11 at lists.hampshire.edu>
>> 
>> 
>> Infinite lazy repeat of a function that requires arguments: repeatedly lets you do it with one without arguments, I'd want to step over prime? with a (range 1 [assumed infinity]). If thats the wrong way to do it maybe I'm missing a better style. 
>> >> https://gist.github.com/1257722
>> 
>> Second issue is with trying to test if #{\3} is in a set.
>> 
>> >> https://gist.github.com/1257724
>> 
>> _______________________________________________
>> Cs254f11 mailing list
>> Cs254f11 at lists.hampshire.edu
>> https://lists.hampshire.edu/mailman/listinfo/cs254f11
> 

--
Lee Spector, Professor of Computer Science
Cognitive Science, Hampshire College
893 West Street, Amherst, MA 01002-3359
lspector at hampshire.edu, http://hampshire.edu/lspector/
Phone: 413-559-5352, Fax: 413-559-5438

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.hampshire.edu/mailman/private/cs254f11/attachments/20111002/5d702b04/attachment.htm>


More information about the Cs254f11 mailing list