From ef08bfe65f3da8a361b150b424d3d8359e5e6968 Mon Sep 17 00:00:00 2001 From: Owen Rodley Date: Sat, 4 May 2013 11:49:41 +1200 Subject: [PATCH] ACONS --- src/list.lisp | 2 ++ src/toplevel.lisp | 2 +- tests/list.lisp | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/list.lisp b/src/list.lisp index 173dedf..09092ad 100644 --- a/src/list.lisp +++ b/src/list.lisp @@ -184,6 +184,8 @@ (setq alist (cdr alist)))) (car alist)) +(defun acons (key datum alist) + (cons (cons key datum) alist)) (define-setf-expander car (x) diff --git a/src/toplevel.lisp b/src/toplevel.lisp index 0bb2b43..c03f370 100644 --- a/src/toplevel.lisp +++ b/src/toplevel.lisp @@ -49,7 +49,7 @@ (values-list /)) (export '(&body &key &optional &rest * ** *** *gensym-counter* *package* + ++ - +++ - / // /// 1+ 1- < <= = = > >= and append apply aref arrayp + +++ - / // /// 1+ 1- < <= = = > >= acons and append apply aref arrayp assoc atom block boundp butlast cadar caaar caadr cdaar cdadr cddar caaaar caaadr caadar caaddr cadaar cadadr caddar cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr caar cadddr caddr diff --git a/tests/list.lisp b/tests/list.lisp index 72da656..7969b0b 100644 --- a/tests/list.lisp +++ b/tests/list.lisp @@ -38,6 +38,12 @@ (test (tailp a a))) (test (tailp 'a (cons 'b 'a))) +; ACONS +; FIXME: Write the alist in a more natural form once #72 has been fixed +(test (equal (cons (cons 1 2) (list (cons 3 4))) + (acons 1 2 (list (cons 3 4))))) +(test (equal (list (cons 1 2)) (acons 1 2 ()))) + ; SUBST ; Can't really test this until EQUAL works properly on lists -- 1.7.10.4