From e9c12ab1d019b42e5427e31bfa49f1f799e84165 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 9 May 2011 12:40:09 +0200 Subject: Rewrite comp/middle/resolve.rs * Cleans up the algorithm * Move first pass to walk (second still folds) * Support part of a type/value namespace split (crate metadata and module indices still need to be taught about this) * Remove a few blatant inefficiencies (import tables being recreated for every lookup, most importantly) --- src/lib/List.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lib') diff --git a/src/lib/List.rs b/src/lib/List.rs index 58ea29f2..6d7748f0 100644 --- a/src/lib/List.rs +++ b/src/lib/List.rs @@ -56,6 +56,17 @@ fn length[T](&list[T] ls) -> uint { ret foldl[T,uint](ls, 0u, bind count[T](_, _)); } +fn cdr[T](&list[T] ls) -> list[T] { + alt (ls) { + case (cons[T](_, ?tl)) {ret *tl;} + } +} +fn car[T](&list[T] ls) -> T { + alt (ls) { + case (cons[T](?hd, _)) {ret hd;} + } +} + // Local Variables: // mode: rust; // fill-column: 78; -- cgit v1.2.3