[xyzzy:07539] Re: stable-sort について
- Subject: [xyzzy:07539] Re: stable-sort について
- From: 大久保博之 <ohkubo@xxxxxxxxxxxxxxxxxxxxx>
- X-mailer: EdMax Ver2.84.2F
大久保です。
At Tue, 18 Sep 2001 16:58:33 +0900
中田 伸悦 <nobu.nokada@xxxxxxxxxxxx> wrote:
> sortした結果を捨てているからでしょう。
すばやい回答ありがとうございました。
xyzzy の ver. 0.2.1.181 の ChangeLog にもしっかりと、
> 従来はたまたま (eq list (sort list)) だったが、そうではな
> くなったので注意すること。
と書いてありました。
不注意恥ずかしいかぎりです。
私はコードを書く際に、逸見さんを初めとした有志による「へなちょこリファ
レンス作成計画」を大変便利に利用させていただいているので、
[xyzzy:06854] に追従して、今後の自分のためにも reference.xml を補完・
更新しておきます。
<!-- xyzzy reference.xml --引用厳禁-->
<chapter>
<title>sort</title>
<type>Function</type>
<arguments>sequence predicate &key :key </arguments>
<package>lisp</package>
<description>
sequenceをpredicateに従った順番に並び替えたものを返す。
元のsequenceは破壊される。(Version 0.2.1.181 以降)
[xyzzy:06221] (こっそり)バージョンアップのお知らせ
|・sort のアルゴリズムを quick から merge に変更
| (比較回数が少ない分、merge の方が速いっぽい)。
| 結果、stable-sort と同じになった(が、依存しないように)。
| 従来は *たまたま* (eq list (sort list)) だったが、
| そうではなくなったので注意すること。
(setq *test-seq* '(("foo") ("bar") ("hoge")))
=> (("foo") ("bar") ("hoge"))
(setq *test-seq* (sort *test-seq* #'string-lessp :key #'car))
=> (("bar") ("foo") ("hoge"))
*test-seq*
=> (("bar") ("foo") ("hoge"))
(setq *test-seq* '(("foo") ("bar") ("hoge")))
=> (("foo") ("bar") ("hoge"))
(sort *test-seq* #'string-lessp :key #'car)
=> (("bar") ("foo") ("hoge"))
*test-seq*
=> (("foo") ("hoge"))
</description>
<section>Sequence</section>
<seealso>stable-sort</seealso>
<seealso>[xyzzy:06221]</seealso>
</chapter>
<chapter>
<title>stable-sort</title>
<type>Function</type>
<arguments>sequence predicate &key :key </arguments>
<package>lisp</package>
<description>
sequenceをpredicateに従った順番に並び替えたものを返す。
元のsequenceは破壊される。
(setq *test-seq* '(("foo") ("bar") ("hoge")))
=> (("foo") ("bar") ("hoge"))
(setq *test-seq* (stable-sort *test-seq* #'string-lessp :key #'car))
=> (("bar") ("foo") ("hoge"))
*test-seq*
=> (("bar") ("foo") ("hoge"))
(setq *test-seq* '(("foo") ("bar") ("hoge")))
=> (("foo") ("bar") ("hoge"))
(stable-sort *test-seq* #'string-lessp :key #'car)
=> (("bar") ("foo") ("hoge"))
*test-seq*
=> (("foo") ("hoge"))
</description>
<section>Sequence</section>
<seealso>sort</seealso>
<seealso>[xyzzy:06221]</seealso>
<file>builtin.l</file>
</chapter>
<!-- end -->
ところで、sort ってどこで定義されているのでしょうか。
よくわからなく<file></file> に書くことができませんでした。
---
大久保博之(OHKUBO Hiroshi)
konata_o@xxxxxxxxxxx
http://members.tripod.co.jp/ohkubo/xyzzy/index.html