natural-compare - xyzzy で自然順ソート

1 説明

xyzzy で自然順ソートを行うためのライブラリです。

※ natural-compare はライブラリでありユーザが直接利用するものではありません。

2 使用例

3 インストール

NetInstaller でインストールした場合は 3 以降で OK です。

  1. アーカイブをダウンロードします。

    <URL:http://miyamuko.s56.xrea.com/xyzzy/archives/natural-compare.zip>

  2. アーカイブを展開して、$XYZZY/site-lisp 配下にファイルをコピーします。
  3. ~/.xyzzy または $XYZZY/site-lisp/siteinit.l に以下のコードを追加します。

    ;; natural-compare
    (require "natural-compare")
  4. 設定を反映させるには xyzzy を再起動してください。

    ※siteinit.l に記述した場合には再ダンプが必要です。

4 リファレンス

natural-compare

natural-compare a b &optional case-fold => -1 or 0 or 1

自然順に比較して a と b が同じなら 0、 a が小さいなら負数を a が b より大きいなら正数を返します。

natural=

Syntax:

natural= a b => t or nil

空白文字を無視して比較します。 大文字小文字の違いは区別します。

Examples:

(natural= "rfc1.txt" "rfc1 .txt")
t
(natural= "rfc1.txt" "rfc01.txt")
nil
(natural= "rfc1.txt" "RFC1.txt")
nil
natural<

Syntax:

natural< a b => t or nil

自然順に比較して a が小さい場合に t を返します。 大文字小文字の違いは区別します。

Examples:

(natural< "rfc1.txt" "rfc1 .txt")
nil
(natural< "rfc1.txt" "RFC1.txt")
nil
(natural< "rfc1.txt" "rfc01.txt")
nil
(natural< "rfc01.txt" "rfc1.txt")
t
(natural< "rfc01.txt" "rfc02.txt")
t
natural>

Syntax:

natural> a b => t or nil

自然順に比較して a が大きい場合に t を返します。 大文字小文字の違いは区別します。

Examples:

(natural> "rfc1.txt" "rfc1 .txt")
nil
(natural> "rfc1.txt" "rfc01.txt")
t
(natural> "rfc01.txt" "rfc1.txt")
nil
(natural> "rfc01.txt" "rfc02.txt")
nil
natural-equal

Syntax:

natural-equal a b => t or nil

natural= の大文字小文字を区別しない版

natural-lessp

Syntax:

natural-lessp a b => t or nil

natural< の大文字小文字を区別しない版

natural-greaterp

Syntax:

natural-greaterp a b => t or nil

natural> の大文字小文字を区別しない版

5 これからやるかもしれないこと

6 関連するかもしれないページ

Natural Order Numerical Sorting
<URL:http://www.naturalordersort.org/>
Natural Order String Comparison
<URL:http://sourcefrog.net/projects/natsort/>

7 ライセンス

natural-compare は修正 BSD ライセンスに基づいて利用可能です。

Copyright (C) 2005 MIYAMUKO Katsuyuki. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1 Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer as the first lines
  of this file unmodified.

2 Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer in the
  documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.