diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/List.rs | 11 |
1 files changed, 11 insertions, 0 deletions
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; |