mll / MLFunctionalPackage

A set of map-filter-reduce tools for Objective-C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MLFunctionalPackage

A set of map-filter-reduce tools for Objective-C

Thanks to blocks Objective-C has the potential to support functional programming style. This library provides the basic map-filter-reduce library functions to further expand this opportunity.

Installation

Use CocoaPods or copy those 2 files directly into the project.

pod 'MLFunctionalPackage'

How to use it?

See the .h file for detailed documentation.
A quick example:

#import <MLFunctionalPackage/MLFunctionalPackage.h>

NSLog(@"%@", [[[[[NSArray rangeFrom:10 to: 21] mll_filter: ^(NSNumber *n) { 
   return n.integerValue % 2 == 0; 
}] mll_map: ^(NSNumber *n) { 
   return [NSString stringWithFormat:@"%d", n.integerValue]; 
}] mll_reduce: ^(NSString *l, NSString *r) { 
   return [NSString stringWithFormat:@"%@, %@", l, r];
}] stringByAppendingString: @"."]);

About

A set of map-filter-reduce tools for Objective-C

License:MIT License


Languages

Language:Objective-C 85.0%Language:Ruby 15.0%