robb / asterism Goto Github PK
View Code? Open in Web Editor NEWAsterism is yet another functional toolbelt for Objective-C. It tries to be typesafe and simple.
Home Page: http://robb.github.io/Asterism/
License: MIT License
Asterism is yet another functional toolbelt for Objective-C. It tries to be typesafe and simple.
Home Page: http://robb.github.io/Asterism/
License: MIT License
This one is a little more tricky since NSCountedSet
inherits from NSMutableSet
.
Since we would want ASTMap(countedSet, block);
to be equivalent to ASTMap((NSSet *)countedSet, block);
, "unrolling" versions of map
et. al. would need an extra parameter.
E.g.:
// if unroll is YES, calls the block multiple times per element.
NSCountedSet *ASTMap(NSCountedSet *set, BOOL unroll, id(^block)(id obj));
like the underscore.js equivalent
Not sure what should happen if the assumption is violated, tho.
Worth it?
Guess it's not worth the trouble after all and it's easy to bring back if need be
That may allow better integration with cocoadocs and Dash. Even though I personally prefer reading TomDoc in the headers, this may be the right thing to do for the community at large.
yay or nay?
… for NSArray
and NSOrderedSet
I find it odd that All and Any methods return NO for empty sets. Formally, I believe, YES should be returned in such cases; according to: https://en.wikipedia.org/wiki/Vacuous_truth#Vacuous_truths_in_mathematics
Additionally, I find I often need to cover an empty-container case manually in my code, because Asterism doesn't return YES in those cases.
Tests probably shouldn't import the commands directly, to make sure this is caught in the future.
I'm having second thoughts about asserting against nil
all over the place, I think it's best and more in the spirit of the surrounding Cocoa framework if stuff like
ASTMap(nil, ^(id obj, NSUInteger index) {
return [obj foo];
});
simply returned nil
.
Essentially:
or:
static inline
defined in the .h
files/cc @wrl
Consider methods that operate only on id<NSFastEnumeration>
such as ASTAll
ASTAll(@{ @"key": @"value" }, someTest);
This will actually evaluate @"key"
rather than @"value"
, which is probably more desired.
However, if we add
BOOL ASTAll(NSDictionary *dict, BOOL(^block)(id value));
later, this may lead to some nasty surprises. Better to pre-empt that now and add dictionary versions that call the existing ones with allValues
.
Affects
ASTAll
ASTAny
ASTGroupBy
ASTIndexBy
ASTMin
ASTMax
ASTPluck
ASTReduce
✨
Write specs where necessary to make sure that ASTWhatever(nil, block) == nil
.
yay or nay?
Those methods would make sense for NSIndexSet:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.