/Asterism

Primary LanguageObjective-C

Asterism ⁂

Asterism is yet another functional toolbelt for Objective-C. It tries to be typesafe and elegant.

NSDictionary *reviewsByRating = ASTGroup(reviews, ASTLift0(rating));

// Log all five star ratings
ASTEach(reviewsByRating[@5], ^(XYReview *review) {
    NSLog(@"%@", review);
});

XYReview *worstReview = ASTMin(reviews);

I'd like Asterism to eventually offer common methods for data structures for all of Cocoa's collections.

Lifting

A notable feature of Asterism is that it allows you to lift selectores into blocks. Together with partial block evaluation, this allows you to write very concise code.

NSArray *files = @[ file1, file2, file3 ];

// Invoke -upload on all files
ASTEach(files, ASTLift0(upload));
XYUser *user = [XYUser me];

NSArray *posts = @[ post1, post2, post3 ];

// Invoke -[XYUser likePost:] on user with every post
ASTEach(posts, ASTPartial(ASTLift(likePost:), user));

Supported Operations

Asterism currently supports the following operations: