ToadGenerators Class Reference

#import <ToadGenerators.h>

List of all members.

Static Public Member Functions

(Generator) + infiniteSequentialInts
(Generator) + rangeFrom:to:
(Generator) + NSArraySeq:
(Generator) + NSDictionarySeq:
(Generator) + Primes

Detailed Description

Generators are blocks that provide the original source of data for the transformations.

Each block is of the form ^id(BOOL *end). Each time they are called they will return the next value in the sequence and will set *end to be NO. When they have run out of data they will set *end to be YES. They should also return nil - although this should not be relied on.

Note that not all generators will end. For example to infiniteSequentialInts will carry on (its behaviour will be undefined at MaxInt.) It is up to you to make sure you only take as many values as you need.


Member Function Documentation

+ (Generator) infiniteSequentialInts  

Returns an infinite sequence of ints. Will be undefined when it gets to MaxInt. Note the sequence is of objects of type NSNumber. If you need to do arithmetic with the values then use the intValue property of the values.

Returns:
The generator
+ (Generator) NSArraySeq: (NSArray *)  arr  

Returns a sequence of the elements of the array.

Parameters:
arr The array containing the elements to create the sequence from
Returns:
The generator
+ (Generator) NSDictionarySeq: (NSDictionary *)  dict  

Returns a sequence of the keys of the dictionary.

Parameters:
dict The dictionary
Returns:
The generator
+ (Generator) Primes  

Returns an infinite (subject to memory and time) sequence of prime numbers

Returns:
The generator
+ (Generator) rangeFrom: (int)  from
to: (int)  to 

Returns a seqence of integers between from and to.

Parameters:
from Start the sequence from this number
to End the sequence after the number.
Returns:
The generator

The documentation for this class was generated from the following files: