From: Owen Rodley Date: Fri, 3 May 2013 23:49:41 +0000 (+1200) Subject: ACONS X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=ef08bfe65f3da8a361b150b424d3d8359e5e6968;p=jscl.git ACONS --- 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