Add vec::member

This commit is contained in:
Marijn Haverbeke 2011-06-09 10:58:31 +02:00
parent 77c1b9650f
commit 43fbb07126

View File

@ -286,6 +286,13 @@ fn find[T](fn (&T) -> bool f, &vec[T] v) -> option::t[T] {
ret none[T];
}
fn member[T](&T x, &array[T] v) -> bool {
for (T elt in v) {
if (x == elt) { ret true; }
}
ret false;
}
fn foldl[T, U](fn (&U, &T) -> U p, &U z, &vec[T] v) -> U {
auto sz = len[T](v);