Discussion:
[Lisp-cn] Common Lisp中,有什么办法将一个用过的数组迅速清理为0?
leo
2015-08-21 09:34:19 UTC
Permalink
就是全部填上0,就像C语言的memset那样
--
--
Lisp-cn(Lisp中文用户组)
CLUG http://lisp.org.cn

---
您收到此邮件是因为您订阅了 Google 网上论坛的“Lisp-cn(Lisp中文用户组)”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到lisp-cn+***@googlegroups.com。
要查看更多选项,请访问 https://groups
Vito Van
2015-08-21 09:43:14 UTC
Permalink
(setf *list-to-be-clear* '(a b c d e f))
(setf *list-to-be-clear* (mapcar #'(lambda(x) (setf x 0)) *list-to-be-clear*))

是这样么

Vito Van Be Alive with Music and Program.
Date: Fri, 21 Aug 2015 17:34:19 +0800
Subject: [Lisp-cn] Common Lisp䞭有什么办法将䞀䞪甚过的数组迅速枅理䞺0
就是党郚填䞊0就像C语蚀的memset那样
--
--
Lisp-cn(Lisp䞭文甚户组)
CLUG http://lisp.org.cn
---
悚收到歀邮件是因䞺悚订阅了 Google 眑䞊论坛的“Lisp-cn(Lisp䞭文甚户组)”矀组。
芁查看曎倚选项请访问 https://groups.google.com/d/optout。
--
--
Lisp-cn(Lisp䞭文甚户组)
CLUG http://lisp.org.cn

---
悚收到歀邮件是因䞺悚订阅了 Google 眑䞊论坛的“Lisp-cn(Lisp䞭文甚户组)”矀组。
芁退订歀矀组并停止接收歀矀组的电子邮件请发送电子邮件到lisp-cn+***@googlegroups.com。
芁查看曎倚选项请访问 https://groups.google.com/d/optout。
leo
2015-08-21 09:47:29 UTC
Permalink
䞍是铟衚我想枅空数组。
Post by Vito Van
(setf *list-to-be-clear* '(a b c d e f))
(setf *list-to-be-clear* (mapcar #'(lambda(x) (setf x 0))
*list-to-be-clear*))
是这样么
* Vito Van*
* Be Alive with Music and Program.
*
Date: Fri, 21 Aug 2015 17:34:19 +0800
Subject: [Lisp-cn] Common Lisp䞭有什么办法将䞀䞪甚过的数组迅速枅理
䞺0
就是党郚填䞊0就像C语蚀的memset那样
--
--
Lisp-cn(Lisp䞭文甚户组)
CLUG http://lisp.org.cn
---
悚收到歀邮件是因䞺悚订阅了 Google 眑䞊论坛的“Lisp-cn(Lisp䞭文甚户
组)”矀组。
芁退订歀矀组并停止接收歀矀组的电子邮件请发送电子邮件到lisp-
芁查看曎倚选项请访问 https://groups.google.com/d/optout。
--
--
Lisp-cn(Lisp䞭文甚户组)
CLUG http://lisp.org.cn
---
悚收到歀邮件是因䞺悚订阅了Google眑䞊论坛䞊的“Lisp-cn(Lisp䞭文甚户组)”
矀组。
芁退订歀矀组并停止接收歀矀组的电子邮件请发送电子邮件到lisp-
芁查看曎倚选项请访问https://groups.google.com/d/optout。
--
--
Lisp-cn(Lisp䞭文甚户组)
CLUG http://lisp.org.cn

---
悚收到歀邮件是因䞺悚订阅了 Google 眑䞊论坛的“Lisp-cn(Lisp䞭文甚户组)”矀组。
芁退订歀矀组并停止接收歀矀组的电子邮件请发送电子邮件到lisp-cn+***@googlegroups.com。
芁查看曎倚选项请访问 https://groups.google.com/d/optout。
蒋文佼
2015-08-21 10:18:14 UTC
Permalink
make-array 初始倌讟0
Post by leo
䞍是铟衚我想枅空数组。
(setf *list-to-be-clear* '(a b c d e f))
(setf *list-to-be-clear* (mapcar #'(lambda(x) (setf x 0))
*list-to-be-clear*))
是这样么
* Vito Van*
* Be Alive with Music and Program. *
Date: Fri, 21 Aug 2015 17:34:19 +0800
Subject: [Lisp-cn] Common Lisp䞭有什么办法将䞀䞪甚过的数组迅速枅理䞺0
就是党郚填䞊0就像C语蚀的memset那样
--
--
Lisp-cn(Lisp䞭文甚户组)
CLUG http://lisp.org.cn
---
悚收到歀邮件是因䞺悚订阅了 Google 眑䞊论坛的“Lisp-cn(Lisp䞭文甚户组)”矀组。
芁查看曎倚选项请访问 https://groups.google.com/d/optout。
--
--
Lisp-cn(Lisp䞭文甚户组)
CLUG http://lisp.org.cn
---
悚收到歀邮件是因䞺悚订阅了Google眑䞊论坛䞊的“Lisp-cn(Lisp䞭文甚户组)”矀组。
芁查看曎倚选项请访问https://groups.google.com/d/optout。
--
--
Lisp-cn(Lisp䞭文甚户组)
CLUG http://lisp.org.cn
---
悚收到歀邮件是因䞺悚订阅了Google眑䞊论坛䞊的“Lisp-cn(Lisp䞭文甚户组)”矀组。
芁查看曎倚选项请访问https://groups.google.com/d/optout。
--
--
Lisp-cn(Lisp䞭文甚户组)
CLUG http://lisp.org.cn

---
悚收到歀邮件是因䞺悚订阅了 Google 眑䞊论坛的“Lisp-cn(Lisp䞭文甚户组)”矀组。
芁退订歀矀组并停止接收歀矀组的电子邮件请发送电子邮件到lisp-cn+***@googlegroups.com。
芁查看曎倚选项请访问 https://groups.google.com/d/optout。
Vito Van
2015-08-21 10:37:49 UTC
Permalink
make-arry 初始倌讟 0 的做法或讞䌚产生 Garbage。
试试这䞪

(setf *arr-to-be-clear* (make-array '(2 3 2) :initial-element "foo"))

(defun arr-clear (array &optional (clear-obj 0))
(let* ((dimensions (array-dimensions array))
(depth (1- (length dimensions)))
(indices (make-list (1+ depth) :initial-element 0)))
(labels ((recurse (n)
(loop for j below (nth n dimensions)
do (setf (nth n indices) j)
collect (if (= n depth)
(setf (apply #'aref array indices) clear-obj)
(recurse (1+ n))))))
(recurse 0))))

(arr-clear *arr-to-be-clear*)

改自http://stackoverflow.com/questions/9549568/common-lisp-convert-between-lists-and-arrays


Vito Van Be Alive with Music and Program.
Date: Fri, 21 Aug 2015 18:18:14 +0800
Subject: Re: [Lisp-cn] Common Lisp䞭有什么办法将䞀䞪甚过的数组迅速枅理䞺0
From: ***@gmail.com
To: lisp-***@googlegroups.com

make-array 初始倌讟0
2015幎8月21日 䞋午5:47于 "leo" <***@outlook.com>写道





䞍是铟衚我想枅空数组。



圚 2015幎08月21日 17:43, Vito Van 写道:




(setf *list-to-be-clear* '(a b c d e f))

(setf *list-to-be-clear* (mapcar #'(lambda(x) (setf x 0))
*list-to-be-clear*))



是这样么




Vito Van

Be Alive with Music and Program.
Date: Fri, 21 Aug 2015 17:34:19 +0800
Subject: [Lisp-cn] Common Lisp䞭有什么办法将䞀䞪甚过的数组迅速枅理䞺0
就是党郚填䞊0就像C语蚀的memset那样
--
--
Lisp-cn(Lisp䞭文甚户组)
CLUG http://lisp.org.cn
---
悚收到歀邮件是因䞺悚订阅了 Google 眑䞊论坛的“Lisp-cn(Lisp䞭文甚户组)”矀组。
芁查看曎倚选项请访问 https://groups.google.com/d/optout。
--

--

Lisp-cn(Lisp䞭文甚户组)

CLUG http://lisp.org.cn



---

悚收到歀邮件是因䞺悚订阅了Google眑䞊论坛䞊的“Lisp-cn(Lisp䞭文甚户组)”矀组。

芁退订歀矀组并停止接收歀矀组的电子邮件请发送电子邮件到lisp-cn+***@googlegroups.com。

芁查看曎倚选项请访问https://groups.google.com/d/optout。










--

--

Lisp-cn(Lisp䞭文甚户组)

CLUG http://lisp.org.cn



---

悚收到歀邮件是因䞺悚订阅了Google眑䞊论坛䞊的“Lisp-cn(Lisp䞭文甚户组)”矀组。

芁退订歀矀组并停止接收歀矀组的电子邮件请发送电子邮件到lisp-cn+***@googlegroups.com。

芁查看曎倚选项请访问https://groups.google.com/d/optout。






--

--

Lisp-cn(Lisp䞭文甚户组)

CLUG http://lisp.org.cn



---

悚收到歀邮件是因䞺悚订阅了Google眑䞊论坛䞊的“Lisp-cn(Lisp䞭文甚户组)”矀组。

芁退订歀矀组并停止接收歀矀组的电子邮件请发送电子邮件到lisp-cn+***@googlegroups.com。

芁查看曎倚选项请访问https://groups.google.com/d/optout。
--
--
Lisp-cn(Lisp䞭文甚户组)
CLUG http://lisp.org.cn

---
悚收到歀邮件是因䞺悚订阅了 Google 眑䞊论坛的“Lisp-cn(Lisp䞭文甚户组)”矀组。
芁退订歀矀组并停止接收歀矀组的电子邮件请发送电子邮件到lisp-cn+***@googlegroups.com。
芁查看曎倚选项请访问 https://groups.google.com/d/optout。
Loading...