supermarin / ObjectiveSugar

ObjectiveC additions for humans. Ruby style.
MIT License
2.17k stars 190 forks source link

Fix example podfile. Add - [NSArray filter:] and - [NSArray foldLeft:reduce:]. #56

Closed notxcain closed 6 years ago

neilco commented 10 years ago

There's already a method for NSArray that performs the exact same job as thefilter method in this pull request. It's called takeWhile (sharing the name with Ruby's take_while).

foldLeft:reduce: looks interesting. Could you provide a couple of more tests with different use cases? Also, can you fix the test description?

it(@"-foldLeft:reduce: returns an object made by applying reduce block for each element of array"

should simply be

it(@"returns an object made by applying reduce block for each element of array"
supermarin commented 10 years ago

I've thought filter is select, since takeWhile stops when the first NO occurs. Btw, the test is using reject instead of filter :smile:

neilco commented 10 years ago

Yep, it is select and not takeWith.

notxcain commented 10 years ago

@neilco take a look at another it()'s. The are composed the same way.

@mneorr Filter operation is from RAC, Rx and Scala. So I thought it would be more familiar. I did't even notice select operation.

ahti commented 10 years ago

How is the status on this? I'd love to have fold ;)

fatuhoku commented 10 years ago

If a fold is implemented, I will switch from https://github.com/leuchtetgruen/Functional.m to use ObjectiveSugar!