@@ -22,8 +22,8 @@ pub enum List<T> {
2222 Nil ,
2323}
2424
25- /// Cregate a list from a vector
26- pub fn from_vec < T : Copy > ( v : & [ T ] ) -> @List < T > {
25+ /// Create a list from a vector
26+ pub pure fn from_vec < T : Copy > ( v : & [ T ] ) -> @List < T > {
2727 vec:: foldr ( v, @Nil :: < T > , |h, t| @Cons ( * h, t) )
2828}
2929
@@ -53,7 +53,7 @@ pub fn foldl<T: Copy, U>(z: T, ls: @List<U>, f: fn(&T, &U) -> T) -> T {
5353 * When function `f` returns true then an option containing the element
5454 * is returned. If `f` matches no elements then none is returned.
5555 */
56- pub fn find < T : Copy > ( ls : @List < T > , f : fn ( & T ) -> bool ) -> Option < T > {
56+ pub pure fn find < T : Copy > ( ls : @List < T > , f : fn ( & T ) -> bool ) -> Option < T > {
5757 let mut ls = ls;
5858 loop {
5959 ls = match * ls {
@@ -88,7 +88,7 @@ pub pure fn is_not_empty<T: Copy>(ls: @List<T>) -> bool {
8888}
8989
9090/// Returns the length of a list
91- pub fn len < T > ( ls : @List < T > ) -> uint {
91+ pub pure fn len < T > ( ls : @List < T > ) -> uint {
9292 let mut count = 0 u;
9393 iter ( ls, |_e| count += 1 u) ;
9494 count
@@ -131,7 +131,7 @@ pure fn push<T: Copy>(ll: &mut @list<T>, vv: T) {
131131*/
132132
133133/// Iterate over a list
134- pub fn iter < T > ( l : @List < T > , f : fn ( & T ) ) {
134+ pub pure fn iter < T > ( l : @List < T > , f : fn ( & T ) ) {
135135 let mut cur = l;
136136 loop {
137137 cur = match * cur {
@@ -145,7 +145,7 @@ pub fn iter<T>(l: @List<T>, f: fn(&T)) {
145145}
146146
147147/// Iterate over a list
148- pub fn each < T > ( l : @List < T > , f : fn ( & T ) -> bool ) {
148+ pub pure fn each < T > ( l : @List < T > , f : fn ( & T ) -> bool ) {
149149 let mut cur = l;
150150 loop {
151151 cur = match * cur {
0 commit comments