Created
October 21, 2013 11:17
-
-
Save dpeek/7082237 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import haxe.macro.Expr; | |
| class Func | |
| { | |
| public static function each<T>(it:Iterable<T>, cb:T -> Void) | |
| { | |
| for (i in it) cb(i); | |
| } | |
| public static function every<T>(it:Iterable<T>, cb:T -> Bool):Bool | |
| { | |
| for (i in it) if (!cb(i)) return false; | |
| return true; | |
| } | |
| public static function and<T>(it:Iterable<T -> Bool>):T -> Bool | |
| { | |
| return function (e:T) return every(it, function(i) return i(e)); | |
| } | |
| macro public static function pluck<A, B>(it:ExprOf<Iterable<A>>, field:String):ExprOf<Iterable<B>> | |
| { | |
| return macro Lambda.map($it, function(i) return i.$field); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment