Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show warning message if copy-tree with non list #476

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/jlatex/jsequences.tex
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,11 @@ \subsection{リスト}
入れこリストである{\em tree}のコピーを返す。
しかし、環状参照はできない。環状リストは、
{\bf copy-object}でコピーできる。
実際に、{\bf copy-tree}は{\tt (subst t t tree)}と簡単に記述される。}
実際に、{\bf copy-tree}は{\tt (subst t t tree)}と簡単に記述される。
なお{\bf copy-tree}は{\em list}しかコピーできず、
{\em integer-vector, float-vector}などは{\bf copy-seq}を使用しないとコピーできず、
{\em interger-vector, float-vector}などを含む{\em list}は{\bf copy-object}を
使用しないとディープコピーできない。}

\funcdesc{mapc}{func arg-list \&rest more-arg-lists}{
{\em arg-list}や{\em more-arg-lists}それぞれのN番目($N=0,1,\cdots$)の要素からなるリストに
Expand Down
5 changes: 4 additions & 1 deletion doc/latex/sequences.tex
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@ \subsection{Lists}
returns the copy of {\em tree} which may be a nested list
but cannot have circular reference. Circular lists can be copied by
{\bf copy-object}.
Actually, {\bf copy-tree} is simply coded as {\tt (subst t t tree)}.}
Actually, {\bf copy-tree} is simply coded as {\tt (subst t t tree)}.
Be careful that {\bf copy-tree} only return the copy of {\em list}.
and you need to use {\bf copy-seq} to copy {\em integer-vector, float-vector}, etc.,
or {\bf copy-object} to deep-copy {\em list} with {\em integer-vector, float-vector} etc.}

\funcdesc{mapc}{func arg-list \&rest more-arg-lists}{
applies {\em func} to a list of N-th elements in {\em arg-list} and each of
Expand Down
5 changes: 4 additions & 1 deletion lisp/l/common.l
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,10 @@ if pos is bigger than the length of list, item is nconc'ed at the tail"
(defun last (x)
(while (consp (cdr x)) (setq x (cdr x)))
x)
(defun copy-tree (x) (subst t t x))
(defun copy-tree (x)
(if (not (listp x))
(warning-message 1 "copy-tree should be used with list: ~A~%" x))
(subst t t x))
(defun copy-list (x) (nreverse (reverse x)))
(defun nreconc (x y) (nconc (nreverse x) y))
(defun rassoc (item alist)
Expand Down