On 13 Jun 2009, at 09:15, Niels Grewe wrote: > Hi again, > > This really is fun! I never thought that implementing fold would be > that much > easier. I have attached a patch and sample code on which I would > like to > get some feedback. I know that there is quite some duplicated code > that > should be refactored into a more generic implementation for arbitrary > collections and HOM-variations. What else is there that could be done > to improve this?
Good catch on the nil test in map. I don't really understand your code. What is the selfArgs array for? You seem to be trying to implement something like NSIndexSet, but I can't really work out why. Did you try running your test program? It references a variable 'lower' which doesn't exist, so it shouldn't even compile... I expect to use a fold method like this: id input = A(@"a", @"b", @"c"); [ETTranscript show: [[input fold] stringByAppendingString: @"letters: "]]; I would then get the output: letters: abc To do this, you need to set arg 2 of the invocation to last value returned (initially to the original arg 2 value) and then invoke with the target set to the next element in the array (or the other way around, for folding the other way). This doesn't require any of the selfArgs-related stuff, so I don't see what it is trying to accomplish. David _______________________________________________ Etoile-dev mailing list [email protected] https://mail.gna.org/listinfo/etoile-dev
