All Projects → google → Functional Objc

google / Functional Objc

Licence: apache-2.0
Functional operators for Objective-C

Programming Languages

operators
16 projects

Projects that are alternatives of or similar to Functional Objc

array-mixer
Powerful, super tiny and easy to use lib to reorder your javascript arrays.
Stars: ✭ 32 (-90.3%)
Mutual labels:  functional
Switzerland
🇨🇭Switzerland takes a functional approach to Web Components by applying middleware to your components. Supports Redux, attribute mutations, CSS variables, React-esque setState/state, etc… out-of-the-box, along with Shadow DOM for style encapsulation and Custom Elements for interoperability.
Stars: ✭ 261 (-20.91%)
Mutual labels:  functional
Function2
Improved and configurable drop-in replacement to std::function that supports move only types, multiple overloads and more
Stars: ✭ 290 (-12.12%)
Mutual labels:  functional
futura
Asynchronous Swift made easy. The project was made by Miquido. https://www.miquido.com/
Stars: ✭ 34 (-89.7%)
Mutual labels:  functional
finger-tree
🌵 Finger tree data structure for JavaScript
Stars: ✭ 20 (-93.94%)
Mutual labels:  functional
Presentations
Collection of presentations for advanced Python topics
Stars: ✭ 264 (-20%)
Mutual labels:  functional
react-stateful-component
Functional stateful React components with sideEffect support
Stars: ✭ 19 (-94.24%)
Mutual labels:  functional
Coconut
Simple, elegant, Pythonic functional programming.
Stars: ✭ 3,422 (+936.97%)
Mutual labels:  functional
venum
Verifiably better, validated Enum for Python
Stars: ✭ 31 (-90.61%)
Mutual labels:  functional
Eslint Plugin Functional
ESLint rules to disable mutation and promote fp in JavaScript and TypeScript.
Stars: ✭ 282 (-14.55%)
Mutual labels:  functional
fefe
Validate, sanitize and transform values with proper TypeScript types and zero dependencies.
Stars: ✭ 34 (-89.7%)
Mutual labels:  functional
FrontEnd-Note
FrontEnd Knowledge Package 📦
Stars: ✭ 14 (-95.76%)
Mutual labels:  functional
Fpp
Functional PHP Preprocessor - Generate Immutable Data Types
Stars: ✭ 282 (-14.55%)
Mutual labels:  functional
trembita
Model complex data transformation pipelines easily
Stars: ✭ 44 (-86.67%)
Mutual labels:  functional
Sequency
⚡️ Type-safe functional sequences for processing iterable data
Stars: ✭ 294 (-10.91%)
Mutual labels:  functional
Swiftz-Validation
A data structure for validations. It implements the applicative functor interface
Stars: ✭ 15 (-95.45%)
Mutual labels:  functional
Typed Immutable
Immutable and structurally typed data
Stars: ✭ 263 (-20.3%)
Mutual labels:  functional
Go Tea
Tea provides an Elm inspired functional framework for interactive command-line programs.
Stars: ✭ 329 (-0.3%)
Mutual labels:  functional
Enso Archive
Looking for Enso, the visual programming language? ➡️ https://github.com/enso-org/enso
Stars: ✭ 305 (-7.58%)
Mutual labels:  functional
Rex
Your RegEx companion.
Stars: ✭ 283 (-14.24%)
Mutual labels:  functional

Apache License Travis

Functional operators for Objective-C

An Objective-C library of functional operators, derived from Swift.Sequence, that help you write more concise and readable code for collection transformations. Foundation collections supported include: NSArray, NSDictionary, NSOrderedSet, and NSSet.

Functional Operators

Filter

Loops over a collection and returns an array that contains elements that meet a condition.

NSArray<NSNumber *> *filteredArray = [@[ @13, @42, @0 ] fbl_filter:^BOOL(NSNumber *value) {
  return value.integerValue > 0;
}];
XCTAssertEqualObjects(filteredArray, @[ @13, @42 ]);

First

Returns the first element in the collection that satisfies a condition.

NSNumber *firstValue = [@[ @13, @42, @100 ] fbl_first:^BOOL(NSNumber *value) {
  return value.integerValue > 20;
}];
XCTAssertEqualObjects(firstValue, @42);

FlatMap

Similar to map, but can also flatten a collection of collections.

NSArray<NSArray<NSNumber *> *> *originalArray = @[ @[ @13, @42 ], @[ @14, @43 ], @[] ];
NSArray<NSNumber *> *flatMappedArray = [originalArray fbl_flatMap:^id(NSArray<NSNumber *> *value) {
  return value.count > 0 ? value : nil;
}];
XCTAssertEqualObjects(flatMappedArray, @[ @13, @42, @14, @43 ]);

ForEach

Invokes a block on each element of the collection in the same order as a for-in loop.

[@[ @13, @42, @100 ] fbl_forEach:^(NSNumber *value) {
  // Invokes this block for values @13, @42, @100
}];

Map

Loops over a collection and applies the same operation to each element in the collection.

NSArray<NSString *> *mappedArray = [@[ @13, @42, @0 ] fbl_map:^id(NSNumber *value) {
  if (value.integerValue == 0) {
    return nil;
  }
  return value.stringValue;
}];
XCTAssertEqualObjects(mappedArray, @[ @"13", @"42", [NSNull null] ]);

Reduce

Combines all items in a collection to create a single value.

NSNumber *reducedValue =
    [@[ @13, @42, @100 ] fbl_reduce:@0
                            combine:^NSNumber *(NSNumber *accumulator, NSNumber *value) {
                              return @(accumulator.integerValue + value.integerValue);
                            }];
XCTAssertEqualObjects(reducedValue, @(13 + 42 + 100));

Zip

Creates an array of pairs built from the two input collections.

NSArray<NSArray *> *zippedArray = [@[ @13, @42, @101 ] fbl_zip:@[ @"100", @"14" ]];
XCTAssertEqualObjects(zippedArray, @[ @[ @13, @"100" ], @[ @42, @"14" ] ]);

Setup

CocoaPods

Add the following to your Podfile:

pod 'FunctionalObjC', '~> 1.0'

Or, if you would also like to include the tests:

pod 'FunctionalObjC', '~> 1.0', :testspecs => ['Tests']

Then, run pod install.

Carthage

Add the following to your Cartfile:

github "google/functional-objc"

Then, run carthage update and follow the rest of instructions.

Import

Import the umbrella header as:

#import <FBLFunctional/FBLFunctional.h>

Or:

#import "FBLFunctional.h"

Or, the module:

@import FBLFunctional;
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].