Explorar o código

added count()

Nicolas Cannasse %!s(int64=19) %!d(string=hai) anos
pai
achega
b602f8198f
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  1. 10 0
      std/Lambda.hx

+ 10 - 0
std/Lambda.hx

@@ -79,4 +79,14 @@ class Lambda<A,B> {
 		return first;
 	}
 
+	/**
+		Count the number of elements in an [Iterator]
+	**/
+	public static function count( it : Iterator<A> ) {
+		var n = 0;
+		for( _ in it )
+			++n;
+		return n;
+	}
+
 }