diff options
Diffstat (limited to 'src/libstd/list.rs')
| -rw-r--r-- | src/libstd/list.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 5feac4ad454..f6cbd9a099b 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -23,7 +23,7 @@ pub enum List<T> { } /// Create a list from a vector -pub pure fn from_vec<T: Copy>(v: &[T]) -> @List<T> { +pub pure fn from_vec<T:Copy>(v: &[T]) -> @List<T> { vec::foldr(v, @Nil::<T>, |h, t| @Cons(*h, t)) } @@ -40,7 +40,7 @@ pub pure fn from_vec<T: Copy>(v: &[T]) -> @List<T> { * * z - The initial value * * f - The function to apply */ -pub fn foldl<T: Copy, U>(z: T, ls: @List<U>, f: fn(&T, &U) -> T) -> T { +pub fn foldl<T:Copy,U>(z: T, ls: @List<U>, f: fn(&T, &U) -> T) -> T { let mut accum: T = z; do iter(ls) |elt| { accum = f(&accum, elt);} accum @@ -53,7 +53,7 @@ pub fn foldl<T: Copy, U>(z: T, ls: @List<U>, f: fn(&T, &U) -> T) -> T { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -pub pure fn find<T: Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> { +pub pure fn find<T:Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> { let mut ls = ls; loop { ls = match *ls { @@ -67,7 +67,7 @@ pub pure fn find<T: Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> { } /// Returns true if a list contains an element with the given value -pub fn has<T: Copy Eq>(ls: @List<T>, elt: T) -> bool { +pub fn has<T:Copy + Eq>(ls: @List<T>, elt: T) -> bool { for each(ls) |e| { if *e == elt { return true; } } @@ -75,7 +75,7 @@ pub fn has<T: Copy Eq>(ls: @List<T>, elt: T) -> bool { } /// Returns true if the list is empty -pub pure fn is_empty<T: Copy>(ls: @List<T>) -> bool { +pub pure fn is_empty<T:Copy>(ls: @List<T>) -> bool { match *ls { Nil => true, _ => false @@ -90,7 +90,7 @@ pub pure fn len<T>(ls: @List<T>) -> uint { } /// Returns all but the first element of a list -pub pure fn tail<T: Copy>(ls: @List<T>) -> @List<T> { +pub pure fn tail<T:Copy>(ls: @List<T>) -> @List<T> { match *ls { Cons(_, tl) => return tl, Nil => fail!(~"list empty") @@ -98,7 +98,7 @@ pub pure fn tail<T: Copy>(ls: @List<T>) -> @List<T> { } /// Returns the first element of a list -pub pure fn head<T: Copy>(ls: @List<T>) -> T { +pub pure fn head<T:Copy>(ls: @List<T>) -> T { match *ls { Cons(copy hd, _) => hd, // makes me sad @@ -107,7 +107,7 @@ pub pure fn head<T: Copy>(ls: @List<T>) -> T { } /// Appends one list to another -pub pure fn append<T: Copy>(l: @List<T>, m: @List<T>) -> @List<T> { +pub pure fn append<T:Copy>(l: @List<T>, m: @List<T>) -> @List<T> { match *l { Nil => return m, Cons(copy x, xs) => { @@ -120,7 +120,7 @@ pub pure fn append<T: Copy>(l: @List<T>, m: @List<T>) -> @List<T> { /* /// Push one element into the front of a list, returning a new list /// THIS VERSION DOESN'T ACTUALLY WORK -pure fn push<T: Copy>(ll: &mut @list<T>, vv: T) { +pure fn push<T:Copy>(ll: &mut @list<T>, vv: T) { ll = &mut @cons(vv, *ll) } */ |
