Changeset 2533
- Timestamp:
- 06/22/03 18:19:30 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/list.lisp
r2531 r2533 2 2 ;;; 3 3 ;;; Copyright (C) 2003 Peter Graves 4 ;;; $Id: list.lisp,v 1. 39 2003-06-22 17:55:45piso Exp $4 ;;; $Id: list.lisp,v 1.40 2003-06-22 18:19:30 piso Exp $ 5 5 ;;; 6 6 ;;; This program is free software; you can redistribute it and/or … … 20 20 (in-package "COMMON-LISP") 21 21 22 (export '(list-length 23 fifth sixth seventh eighth ninth tenth 24 make-list 25 copy-list copy-alist copy-tree 26 revappend nconc 27 butlast nbutlast 28 ldiff 29 complement constantly 30 sublis nsublis 31 member member-if member-if-not tailp adjoin 32 acons pairlis 33 assoc assoc-if assoc-if-not rassoc rassoc-if rassoc-if-not 34 mapc mapcan mapl maplist mapcon)) 35 36 (defun list-length (list) 37 (do ((n 0 (+ n 2)) 38 (y list (cddr y)) 39 (z list (cdr z))) 40 (()) 41 (when (endp y) (return n)) 42 (when (endp (cdr y)) (return (+ n 1))) 43 (when (and (eq y z) (> n 0)) (return nil)))) 22 (autoload 'list-length) 44 23 45 24 (defun fifth (list) … … 59 38 (%make-list size initial-element)) 60 39 61 (defun copy-list (list) 62 (if (atom list) 63 list 64 (let ((result (list (car list)))) 65 (do ((x (cdr list) (cdr x)) 66 (splice result 67 (cdr (rplacd splice (cons (car x) '()))))) 68 ((atom x) 69 (unless (null x) 70 (rplacd splice x)))) 71 result))) 40 (autoload 'copy-list) 72 41 73 42 (defun copy-tree (object) … … 76 45 object)) 77 46 78 (defun revappend (x y) 79 (do ((top x (cdr top)) 80 (result y (cons (car top) result))) 81 ((endp top) result))) 82 47 (autoload 'revappend) 83 48 (autoload '(butlast nbutlast) "butlast.lisp") 84 49 (autoload 'ldiff) … … 102 67 (%member item list key test test-not)) 103 68 104 (defun member-if (test list &key key) 105 (do ((list list (cdr list))) 106 ((endp list) nil) 107 (if (funcall test (apply-key key (car list))) 108 (return list)))) 109 110 (defun member-if-not (test list &key key) 111 (do ((list list (cdr list))) 112 ((endp list) ()) 113 (if (not (funcall test (apply-key key (car list)))) 114 (return list)))) 115 116 (defun tailp (object list) 117 (do ((list list (cdr list))) 118 ((atom list) (eql list object)) 119 (if (eql object list) 120 (return t)))) 121 122 (defun adjoin (item list &key key (test #'eql) (test-not nil notp)) 123 (if (let ((key-val (apply-key key item))) 124 (if notp 125 (member key-val list :test-not test-not :key key) 126 (member key-val list :test test :key key))) 127 list 128 (cons item list))) 69 (autoload '(member-if member-if-not) "member-if.lisp") 70 (autoload 'tailp) 71 (autoload 'adjoin) 129 72 130 73 (autoload '(union nunion
Note: See TracChangeset
for help on using the changeset viewer.