Browse Source

added count()

Nicolas Cannasse 19 years ago
parent
commit
b602f8198f
1 changed files with 10 additions and 0 deletions
  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;
+	}
+
 }