diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index ebf99a996de..64169dd47ac 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -356,11 +356,10 @@ fn visit_block_with_scope(b: ast::blk, sc: scopes, v: vt) { } fn visit_decl_with_scope(d: @decl, sc: scopes, v: vt) { - let loc_pos = - alt list::car(sc) { - scope_block(_, _, pos) { pos } - _ { @mutable 0u } - }; + let loc_pos = alt list::head(sc) { + scope_block(_, _, pos) { pos } + _ { @mutable 0u } + }; alt d.node { decl_local(locs) { for (_, loc) in locs { v.visit_local(loc, sc, v);; *loc_pos += 1u; } diff --git a/src/lib/list.rs b/src/lib/list.rs index 07605d995c7..9ec762edd3d 100644 --- a/src/lib/list.rs +++ b/src/lib/list.rs @@ -105,20 +105,20 @@ fn len(ls: list) -> uint { } /* -Function: cdr +Function: tail Returns all but the first element of a list */ -fn cdr(ls: list) -> list { +fn tail(ls: list) -> list { alt ls { cons(_, tl) { ret *tl; } nil. { fail "list empty" } } } /* -Function: car +Function: head Returns the first element of a list */ -fn car(ls: list) -> T { +fn head(ls: list) -> T { alt ls { cons(hd, _) { ret hd; } nil. { fail "list empty" } } } diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs index abf2ec0d039..6bd044c9574 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -14,7 +14,7 @@ pure fn nonempty_list(ls: list) -> bool { pure_length(ls) > 0u } // knowledge that ls is a cons node. Future work. // Also, this is pretty contrived since nonempty_list // could be a "tag refinement", if we implement those. -fn safe_head(ls: list) : nonempty_list(ls) -> T { car(ls) } +fn safe_head(ls: list) : nonempty_list(ls) -> T { head(ls) } fn main() { let mylist = cons(@1u, @nil); diff --git a/src/test/run-pass/unchecked-predicates.rs b/src/test/run-pass/unchecked-predicates.rs index a855f96297d..e33c080e64f 100644 --- a/src/test/run-pass/unchecked-predicates.rs +++ b/src/test/run-pass/unchecked-predicates.rs @@ -22,7 +22,7 @@ pure fn nonempty_list(ls: list) -> bool { pure_length(ls) > 0u } // knowledge that ls is a cons node. Future work. // Also, this is pretty contrived since nonempty_list // could be a "tag refinement", if we implement those. -fn safe_head(ls: list) : nonempty_list(ls) -> T { car(ls) } +fn safe_head(ls: list) : nonempty_list(ls) -> T { head(ls) } fn main() { let mylist = cons(@1u, @nil); diff --git a/src/test/stdtest/list.rs b/src/test/stdtest/list.rs index 9b0b78bb810..453ed7fc9ba 100644 --- a/src/test/stdtest/list.rs +++ b/src/test/stdtest/list.rs @@ -1,25 +1,25 @@ use std; import std::list; -import std::list::car; -import std::list::cdr; +import std::list::head; +import std::list::tail; import std::list::from_vec; import std::option; #[test] fn test_from_vec() { let l = from_vec([0, 1, 2]); - assert (car(l) == 0); - assert (car(cdr(l)) == 1); - assert (car(cdr(cdr(l))) == 2); + assert (head(l) == 0); + assert (head(tail(l)) == 1); + assert (head(tail(tail(l))) == 2); } #[test] fn test_from_vec_mut() { let l = from_vec([mutable 0, 1, 2]); - assert (car(l) == 0); - assert (car(cdr(l)) == 1); - assert (car(cdr(cdr(l))) == 2); + assert (head(l) == 0); + assert (head(tail(l)) == 1); + assert (head(tail(tail(l))) == 2); } #[test]