Add vec::member
This commit is contained in:
parent
77c1b9650f
commit
43fbb07126
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user