(examples-for iso ("(nil) is not the same as nil" (iso '(nil) nil) nil)) (examples-for pair? (" t for a cons" (pair? '(1 a 2 b 3 c)) t) ("nil for a number" (pair? 1) nil) ("nil for a string" (pair? "werwe") nil) ("nil for a hash" (pair? {a 1 b 2}) nil) ("nil for a symbol" (pair? 'foo) nil)) (examples-for pairs ("'pair breaks a list into pairs" (pairs '(1 a 2 b 3 c)) ((1 a) (2 b) (3 c)))) (examples-for rev ("'rev reverses a list" (rev '(a b c)) (c b a)) ("'rev reverses a list, appending another list" (rev '(a b c) '(x y z)) (c b a x y z)) ("'rev reverses a list, appending an improper ending" (rev '(a b c) 'surprise) (c b a . surprise)) ("'rev handles nil" (rev nil) nil) ("'rev doesn't recurse" (rev '(a b (c d e) f g)) (g f (c d e) b a))) (examples-for flatten ("'flatten returns a flat list of things" (flatten '((poo (x) (* x x)) (1 2 3))) (poo x * x x 1 2 3))) (examples-for joinlists ("joins one list to another" (joinlists '(a b c) '(x y z)) (a b c x y z)) ("joins three lists" (joinlists '(a b c) '(x y z) '(1 2 3)) (a b c x y z 1 2 3)) ("nil disappears" (apply joinlists '( (a b c) (d e f) nil (j k l) ) ) (a b c d e f j k l)) ("joins three lists without recursing" (joinlists '(a b c) '(x (y1 y2 y3) z) '(1 2 (3 3 3))) (a b c x (y1 y2 y3) z 1 2 (3 3 3)))) (examples-for firstn ("returns no items for n = 0" (firstn 0 '(a b c d)) nil) ("returns first n items for n > 0 and n < size of list" (firstn 3 '(a b c d e)) (a b c)) ("returns all items for n > size of list" (firstn 33 '(a b c d e)) (a b c d e))) (examples-for nthcdr ("returns all items for n = 0" (nthcdr 0 '(a b c d)) (a b c d)) ("returns nth cdr of list for n > 0 and n < size of list" (nthcdr 3 '(a b c d e)) (d e)) ("returns nothing for n = size of list" (nthcdr 5 '(a b c d e)) nil) ("returns nothing for n > size of list" (nthcdr 33 '(a b c d e)) nil)) (examples-for caar ("caar of list" (caar '((x y) (1 2))) x ) ("caar of nil" (caar nil) nil )) (examples-for cadr ("cadr of list" (cadr '((x y) (1 2))) (1 2) ) ("cadr of nil" (cadr nil) nil )) (examples-for cdar ("cdar of list" (cdar '((x y) (1 2))) (y) ) ("cdar of nil" (cdar nil) nil )) (examples-for cddr ("cddr of list" (cddr '(x y 1 2)) (1 2) ) ("cddr of nil" (cddr nil) nil )) (examples-for cadar ("cadar of list" (cadar '((x y) (1 2))) y ) ("cadar of nil" (cadar nil) nil )) (examples-for caddr ("caddr of list" (caddr '(x y 1 2)) 1 ) ("caddr of nil" (caddr nil) nil )) (examples-for cdddr ("cdddr of list" (cdddr '(x y 1 2)) (2) ) ("cdddr of nil" (cdddr nil) nil )) (examples-for cadddr ("cadddr of list" (cadddr '(x y 1 2 3)) 2 ) ("cadddr of nil" (cadddr nil) nil )) (examples-for proper? ("t for a proper list" (proper? '(a b c d)) t) ("t for a proper list, even if we write it funny" (proper? '(a b . (c d))) t) ("t for a proper list, even if we write it funny with nil" (proper? '(a b . nil)) t) ("nil for an improper list" (proper? '(a b . c)) nil) ("nil for a very improper list" (proper? '(a b . (c . d))) nil)) (examples-for list-slices ("just the list if small" (list-slices '(a b c d e) 12) ((a b c d e))) ("nothing but the list if the list is exactly the length of the page" (list-slices '(a b c) 3) ((a b c))) ("exactly three lists" (list-slices '(a b c d e f g h i) 3) ((a b c) (d e f) (g h i))) ("three lists and an extra big" (list-slices '(a b c d e f g h i j k) 3) ((a b c) (d e f) (g h i) (j k)))) (examples-for assoc ("finds nothing in an empty list" (assoc 'foo nil) nil) ("finds nothing in a non-list" (assoc 'foo 'bar) nil) ("finds nothing for nonexistent key" (assoc 'z '((a b) (c d))) nil) ("finds value corresponding to given key" (assoc 'c '((a b) (c d))) (c d))) (examples-for alref ("finds nothing in an empty list" (alref 'foo nil) nil) ("finds nothing for nonexistent key" (alref 'z '((a b) (c d))) nil) ("finds value corresponding to given key" (alref 'c '((a b) (c d))) d))