Ah thank you, now I am un-stuck.

ISeq really only exists for Java interop right?  You don't really 
implement new sequence data types, rather you combine things like 
ITERATE and MAPCAT with your own functions to define your own sequences.

Is it correct to say that sequences are not really a type of data, as 
much as the control structure-- they take the place of WHILE, FOR, LOOP 
etc. in Clojure.

Thanks
P




Stuart Halloway wrote:
> Hi Peter,
>
> For the sequence of positive integers: (iterate inc 1)
>
> Take a look at the lazy-seqs library in Clojure-Contrib for some more  
> interesting lazy sequences.
>
> Cheers,
> Stuart
>
>   
>> Hello all, I am just about to write my first Clojure code to teach
>> myself the language.
>>
>> I thought I might try Bulls&Cows aka Mastermind.  This is the game  
>> where
>> one player hides a pattern of colors, the other guesses a pattern, and
>> the first says something like "1 correct color in the right place,  
>> and 2
>> correct colors in the wrong places".  I want the computer to guess the
>> pattern.
>>
>> The algorithm I want to use is to generate the set of all possible
>> answers, select one at random as the guess, and then successively  
>> remove
>> those inconsistent with the set of responses received so far.  This
>> approach turns out to be close to optimal and the set of consistent
>> guesses shrinks rapidly.
>>
>> I want to do this with sequence and filters.  I want to make my own  
>> kind
>> of lazy sequence that is the set of all possible guesses, and then
>> filter it for consistency with the responses.
>>
>> My problem is getting my mind around the Sequence interface.  I don't
>> really understand how to make my own "type" of sequence.  I don't  
>> really
>> want a List, Vector or Map-- I want an infinite sequence defined by an
>> algorithm.
>>
>> In Java I would expect to define my own class that implements the ISeq
>> interface.  What is the Clojure equivalent?
>>
>> For example, how would one make the sequence of all positive integers?
>> I'm sure it's trivial, but it will un-stick me.
>>
>> Also I haven't found the right document/screencast that talks about
>> this.  Can someone give me a pointer.
>>
>> Thanks in advance
>> Peter
>>
>>
>>
>>     
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to