Alexandriaのマニュアル(ドラフト版)を訳したよ

CLikiの推奨ライブラリでもあり、(http://www.cliki.net/Current%20recommended%20libraries)、モダンなCommon Lispの標準でもある(http://modern-cl.blogspot.jp/2011/04/4-common-lisp.html)ユーティリティライブラリ、Alexandriaのマニュアルを訳したよ。

注意

  • 訳したのはドラフト版のマニュアル(http://common-lisp.net/project/alexandria/draft/alexandria.htm)だよ。
    • 半分以上は動作未検証だよ
    • 訳がわかんなかったとこだけ動かしたよ
  • 割とてきとーな訳だよ。
    • 訳すのがめんどくさくなって書き下したところは原文を一緒に載せているよ
    • ??ってかかれてるのはわかんなかった所、訳が怪しいところだよ
    • ツッコミ歓迎だよ。
  • 島は移動しないよ
  • 眠いよ

Contents

1 Hash Tables
2 Data and Control Flow
3 Conses
4 Sequences
5 Macro Writing
6 Symbols
7 Arrays
8 Types
9 Numbers

Hash Tables(ハッシュテーブル)

— Function: ensure-gethash key hash-table &optional default

gethash のように動作する。しかし keyhash-table に見つけられなければ、値を返す前に key に対応する値として default をハッシュテーブルに登録し、それを返す。

第二の返り値は、値がすでにハッシュテーブルにあれば真となる。

— Function: copy-hash-table table &key key test size rehash-size rehash-threshold

table と同じキーと値を持ったハッシュテーブルのコピーを返す。コピーは、キーワード引数で上書きされたもの以外は、オリジナルと同じ属性を持つ。

オリジナルの値に対しては、新しいハッシュテーブルに登録される前に、key が呼び出される。 key はデフォルトでは cl:identity であるので、浅いコピーがデフォルトでは返る。

— Function: maphash-keys function table

maphash のようなものだが、 table ハッシュテーブルのキーに対してだけfunction を呼び出す。

— Function: maphash-values function table

maphash のようなものだが、 table ハッシュテーブルの値に対してだけfunction を呼び出す。

— Function: hash-table-keys table

ハッシュテーブル table のキーのリストを返す

— Function: hash-table-values table

ハッシュテーブル table の値のリストを返す

— Function: hash-table-alist table

ハッシュテーブル table と同じキーと値を持つ連想リストを返す。

— Function: hash-table-plist table

ハッシュテーブル table と同じキーと値を持つ属性リストを返す。

— Function: alist-hash-table alist &rest hash-table-initargs

連想リスト alist とおなじキーと値を持つハッシュテーブルを返す。ハッシュテーブルは hash-table-initargs を使って初期化される。

— Function: plist-hash-table plist &rest hash-table-initargs

属性リスト plist とおなじキーと値を持つハッシュテーブルを返す。ハッシュテーブルは hash-table-initargs を使って初期化される。

Data and Control Flow(データと制御構造)

— Macro: define-constant name initial-value &key test documentation

name によって名付けられるグローバル変数が、初期値 initial-value の評価結果にtestのもとで等しい値として一定になることを保証する。testは関数指示子であり、デフォルトではeqlである。もしドキュメンテーションが与えられていれば、それは定数のドキュメンテーション文字列となる。

もしnameがすでに定数でない変数として束縛されていればエラーを通知する。

もしnameがすでに評価の結果testのもとで等価でない定数に束縛されていればエラーを通知する。

訳注:defconstant は、再定義してもエラーを投げず、 warning を発するだけである。

— Macro: destructuring-case keyform &body clauses

destructuring-case, -ccase そして -ecase は、 casedestructuring-bind のコンビネーションである。keyform はコンスに評価されねばならない。

Clauses は次のようなフォームである。

            ((CASE-KEYS . DESTRUCTURING-LAMBDA-LIST) FORM*)

case-keyskeycar 部と、 case, ccase, ecase のようにマッチした節が選択され、FORMdestructuring-lambda-list にしたがって分解・束縛された状態で実行さる。

Example:

           (defun dcase (x)
             (destructuring-case x
               ((:foo a b)
                (format nil "foo: ~S, ~S" a b))
               ((:bar &key a b)
                (format nil "bar, ~S, ~S" a b))
               (((:alt1 :alt2) a)
                (format nil "alt: ~S" a))
               ((t &rest rest)
                (format nil "unknown: ~S" rest))))
     
            (dcase (list :foo 1 2))        ; => "foo: 1, 2"
            (dcase (list :bar :a 1 :b 2))  ; => "bar: 1, 2"
            (dcase (list :alt1 1))         ; => "alt: 1"
            (dcase (list :alt2 2))         ; => "alt: 2"
            (dcase (list :quux 1 2 3))     ; => "unknown: 1, 2, 3"
     
           (defun decase (x)
             (destructuring-case x
               ((:foo a b)
                (format nil "foo: ~S, ~S" a b))
               ((:bar &key a b)
                (format nil "bar, ~S, ~S" a b))
               (((:alt1 :alt2) a)
                (format nil "alt: ~S" a))))
     
            (decase (list :foo 1 2))        ; => "foo: 1, 2"
            (decase (list :bar :a 1 :b 2))  ; => "bar: 1, 2"
            (decase (list :alt1 1))         ; => "alt: 1"
            (decase (list :alt2 2))         ; => "alt: 2"
            (decase (list :quux 1 2 3))     ; =| error

— Macro: multiple-value-prog2 first-form second-form &body forms

prog2の多値版。フォームを順に評価し、2番めのフォームから返される値を返す。フォームから返される値が多値ならば、多値を返す。

Evaluates first-form, then second-form, and then forms. Yields as its value all the value returned by second-form.

訳注: prog
prog, prog*
let, block, tagbody を合わせて使える邪悪なマクロ。Lispを手続き型に変える程度の能力を持つ。かつて広く使われていたという。
progn
おなじみのアレ。多値を返すことができる。
prog1, prog2
progn と同じだが、値を返すのが最後のフォームではなく、1番目(2番め)のフォームになっているのが特徴。多値を返せないという欠点を持つ。
multiple-value-prog1
多値を返せるようになったprog1.

— Macro: named-lambda name lambda-list &body body

名前付きの lambda再帰ができる。展開形としては、 labels で作った関数を返すクロージャである。

Expands into a lambda-expression within whose body name denotes the corresponding function.

— Macro: nth-value-or nth-value &body forms

複数の、多値を返す関数に対しての OR 。forms を順に評価していき、返された多値の第 nth-value 要素が nil でなければ、そのフォームから返された多値を返す。このとき、残りのフォームは評価されない(短絡)。 nth-value に0を指定すれば or と同じに使える。ただ、orは元々多値を返せるっぽい。対応するのは多値に対してでリストにではないことに注意。

Evaluates form arguments one at a time, until the nth-value returned by one of the forms is true. It then returns all the values returned by evaluating that form. If none of the forms return a true nth value, this form returns nil.

— Macro: if-let bindings &body (then-form &optional else-form)

新たな変数束縛を作り、 then-formelse-form を条件付き実行する。else-form はデフォルトでは nil である。

bindings は次のような1つの束縛フォームであるか、

           (variable initial-form)

束縛フォームのリストでなければならない。

           ((variable-1 initial-form-1)
            (variable-2 initial-form-2)
            ...
            (variable-n initial-form-n))

初期化フォームが仕様順に評価され、変数が対応する値に束縛される。

もしすべての変数が真値に束縛されていれば then-form が、そうでなければ else-form が束縛のもとで実行される。

— Macro: when-let bindings &body forms

新しい束縛を作り、 forms を条件付き実行する。bindings は次のような1つの束縛フォームであるか、

           (variable initial-form)

あるいは次のような束縛フォームのリストでなければならない。

           ((variable-1 initial-form-1)
            (variable-2 initial-form-2)
            ...
            (variable-n initial-form-n))

すべての 初期化フォームが仕様順に実行され、対応する変数に束縛される。

もしすべての変数が真値に束縛されていれば、formsが暗黙のprognとして実行される。

— Macro: when-let* bindings &body forms

新たな変数束縛を作り、 then-formelse-form を条件付き実行する。

bindings は次のような1つの束縛フォームであるか、

           (variable initial-form)


あるいは次のような束縛フォームのリストでなければならない。

           ((variable-1 initial-form-1)
            (variable-2 initial-form-2)
            ...
            (variable-n initial-form-n))


それぞれの初期化フォームが順に実行され、対応する変数に束縛される。初期化フォーム式は when-let* による、より前の変数を参照できる。

when-let* の実行は初期化フォームのいずれかがnilに評価された時ただちに停止する。もしすべての初期化フォームが真値に評価されたならば、 forms が暗黙のprognの内で実行される。

— Macro: switch whole (object &key test key) &body clauses

はじめにマッチした節を評価し、その値を返すか、もしどのキーもマッチしなければ、評価して default の値を返す。

— Macro: cswitch whole (object &key test key) &body clauses

switchと同様に動作するが、どのキーもマッチしなければ継続可能なエラーが発生する。

— Macro: eswitch whole (object &key test key) &body clauses

switchと同様に動作するが、どのキーもマッチしなければエラーが発生する。

— Macro: whichever &rest possibilities env

possibilities のうちランダムに選ばれた1つだけを評価する。

— Macro: xor &rest datums

引数を左から右に一度に評価する。1つより多くの引数が真値に評価されたとき、残りの引数の評価は直ちに中止され、nil nil が返される。もしたった1つだけの引数が真値に評価されたとき、その値が第一の返り値、第二の返り値として t が返る。もしすべての引数が nil に評価されたとき、第一の返り値として nil 、第二の返り値として t が返る。

— Function: disjoin predicate &rest more-predicates

predicate および more-predicates を順に適用していき、はじめて真を返した述語の第一返り値を残りの述語を適応せずにただちに返すか、いずれも真を返さなければ nil を返す関数を返す。

— Function: conjoin predicate &rest more-predicates

predicate および more-predicates を順に適用していき、いずれかでも偽を返したときは残りの述語を適応せずにただちにnilを返すか、いずれも真を返せば最後の述語の第一返り値を返す関数を返す。

— Function: compose function &rest more-functions

合成関数を返す。引数に対して、最も右の関数から適用し、第一返り値を左の関数に渡す。

Returns a function composed of function and more-functions that applies its arguments to to each in turn, starting from the rightmost of more-functions, and then calling the next one with the primary value of the last.

— Function: ensure-function function-designator

function-designator で示される関数を返す。もし function-designator が関数ならばそのまま返し、そうでなければ fdefinition を呼び出す。

訳注: function-designator はシンボルあるいは carsetf であるリストでなければならない。

訳注2: fdefinitionsymbol-definition とだいたい同じらしいが違いがよくわからない。

— Function: multiple-value-compose function &rest more-functions

compose のような合成関数を返す。ただし、多値が返された時、その値はすべて次の関数への引数となる(つまり mutiple-value-call っぽく動作する)。

Returns a function composed of function and more-functions that applies its arguments to each in turn, starting from the rightmost of more-functions, and then calling the next one with all the return values of the last.

— Function: curry function &rest arguments

関数を返す。返された関数は任意の引数を取り、 arguments の後にその引数をつけくわえて function を適用する。

Returns a function that applies arguments and the arguments it is called with to function.

— Function: rcurry function &rest arguments

関数を返す。返された関数は任意の引数を取り、 arguments の前にその引数をつけくわえて function を適用する。

Returns a function that applies the arguments it is called with and arguments to function.

Conses(コンス)

— Type: proper-list

属性リストのための型指示子。 satisfies 型指定子として実装されているので、パフォーマンスが要求される使用には推奨できない。主な使い道は type-error の時の expected type に使われる型指示子。

— Type: circular-list

循環リストのための型指示子。 satisfies 型指定子として実装されているので、パフォーマンスが要求される使用には推奨できない。主な使い道は type-error の時の expected type に使われる型指示子。

— Macro: appendf place &rest lists env

append のためのモディファイマクロ。 lists を第一引数で示される場所に連結する。

— Macro: nconcf place &rest lists env

nconc のためのモディファイマクロ。 lists を第一引数で示される場所に破壊的に連結する。

— Macro: remove-from-plistf place &rest keys env

remove-from-plist のためのモディファイマクロ。

— Macro: delete-from-plistf place &rest keys env

delete-from-plist のためのモディファイマクロ。

— Macro: reversef place env

reverse のためのモディファイマクロ。 場所 place に蓄えられたリストをコピーして逆順にし、同じ場所に記録する。

— Macro: nreversef place env

nreverse のためのモディファイマクロ。 place にあるリストを破壊的に逆順にし、同じ場所に記録する。

— Macro: unionf place list &rest args env

union のためのモディファイマクロ。第一引数で示される場所 place のリストと list の和集合を、place にセーブする。

— Macro: nunionf place list &rest args env

nunion のためのモディファイマクロ。第一引数で示される場所 place のリストと、 list の和集合を、place にセーブする。 place 以外の引数は変更される可能性がある。

— Macro: doplist (key val plist &optional values) &body body

plist の要素の上で繰り返しを行う。 bodytagbodyのようなもので、宣言で始まってよい。returnが繰り返しを中断させるために使える。returnが使われなければ、valuesが返される。

— Function: circular-list-p object

もし object が循環リストなら t そうでなければ nil を返す。

— Function: circular-tree-p object

もし object が循環ツリーなら t そうでなければ nil を返す。

— Function: proper-list-p object

もし object が真のリスト(ドットリストでないリスト)なら真を返す。

— Function: alist-plist alist

連想リスト alist に含まれるキー及び値を同じ順番で含む属性リストを返す。

— Function: plist-alist plist

属性リスト plist に含まれるキー及び値を同じ順番で含む連想リストを返す。

— Function: circular-list &rest elements

elements の循環リストを作る。

— Function: make-circular-list length &key initial-element

初期値 initial-element を含む、長さ length の循環リストを作る。

— Function: ensure-car thing

もし thing がコンスならそのcar部が、そうでなければ thing それ自体を返す。

— Function: ensure-cons cons

cons がコンスならば、それ自体が、そうでなければcons がcar部に、nilがcdr部にあるコンスを返す。

— Function: ensure-list list

もしも list がリストなら、そのまま返す。そうでなければ、listを要素とするリストにして返す。

— Function: flatten tree

tree を順に渡り歩き、 nil でない葉の集合であるリストを返す。

— Function: lastcar list

list の最後の要素を返す。 list が真のリストでなければエラーになる。

— Function: (setf lastcar)

最後の要素にセットする。真のリストでなければエラーになる。

— Function: proper-list-length list

list の長さを返すが真のリストでなければエラーを発生させる

訳注: length でも同様のエラーが発生するが、(clispの場合)CLtL2にはそうせねばならない旨は書かれていないようだ。(2012/07/02)

— Function: mappend function &rest lists

それぞれの lists のそれぞれの要素に function を適用し、結果リストをすべて append する。function はリストを返さなければならない。

— Function: map-product function list &rest more-lists

list から要素を1つ、そして more-lists からも1つずつ要素を取り出す、その取り出し方の組み合わせごとに関数を呼び出した結果を含むリストを返す。別の言い方をすると、listmore-listの直積集合にfunctionを適用した結果のリストを返す。

Returns a list containing the results of calling function with one argument from list, and one from each of more-lists for each combination of arguments. In other words, returns the product of list and more-lists using function.

Example:

           (map-product 'list '(1 2) '(3 4) '(5 6))
            => ((1 3 5) (1 3 6) (1 4 5) (1 4 6)
                (2 3 5) (2 3 6) (2 4 5) (2 4 6))


— Function: remove-from-plist plist &rest keys

属性リスト plist と同じキーと値を持つ属性リストを返す。
ただし、keys に含まれるキーとそれに対応する値は含まれない。
返される属性リストは plist と構造を共有するが、
plist は破壊的に変更されることはない。
キーは EQ で比較される。

— Function: delete-from-plist plist &rest keys

remove-from-plist と同じように動作するが、属性リスト plist は破壊的に変更される可能性がある。

— Function: set-equal list1 list2 &key test key

list1 のすべての要素が list2 のいずこかに含まれ、 list2 のすべての要素が list1 のいずこかに含まれれば真、そうでなければ偽を返す。

— Function: setp object &key test key

object が集合を表すリストなら真、さもなければnilを返す。集合を表すリストとは、その要素が key および test のもとでユニークであるリストである。

Sequences(シーケンス)

— Type: proper-sequence

真のシーケンスのための型指定子である。真のシーケンスとは、真のリストとリストでないシーケンスである。

— Macro: deletef place item &rest remove-keywords env

delete のためのモディファイマクロ。第一引数で示される場所 place に、itemplace そして remove のためのを引数を渡して、 delete を呼び出した結果をセットする。

— Macro: removef place item &rest remove-keywords env

remove のためのモディファイマクロ。第一引数で示される場所 place に、itemplace そして remove のためのを引数を渡して、 remove を呼び出した結果をセットする。

— Function: rotate sequence &optional n

sequencen だけ回転させた、 sequence と同じ型のシーケンスを返す。nが正なら末尾の要素が先頭に、nが負なら先頭の要素が末尾に移動する。sequence はプロパーなシーケンスでなければならない。n は整数でなければならず、デフォルトは1である。

もし n の絶対値が sequence の長さより大きければ、その結果はn が (* (signum n) (mod n (length sequence))) で呼び出された時とおなじになる。

注意:オリジナルの sequence は破壊的に変更される可能性があり、また返り値と構造を共有する可能性がある。

— Function: shuffle sequence &key start end

start から end までの範囲をランダムに並び替えられた sequence を返す。変更されたシーケンスは記憶領域を元のシーケンスと共有する可能性がある。もし sequence が真のリストでなければエラーを通知する。

訳注:

(let ((str (list 'a 'b 'c)))
  (alexandria:shuffle str)
  str)

とかするとランダムな順序のリストが返される超パワー。破壊的だと思ったほうがよさそう(つまりこの使い方は正しくない)。

— Function: random-elt sequence &key start end

sequencestart から end までの要素の1つをランダムで返す。真のシーケンスでなければエラーを通知する。

— Function: emptyp sequence

sequence が空なら t を返す。もしシーケンスでなければエラーを通知する。

— Function: sequence-of-length-p sequence length

sequence の長さがlength ならば真を返す。sequence がシーケンスでなければエラーを通知する。循環リストに対しては偽を返す。

— Function: length= &rest sequences

任意のシーケンス、あるいは整数を任意の順で取る。もしすべてのシーケンスの長さと整数が等しければ真値を返す。ヒント:もし第一引数が整数リテラルならばより効率的なコードに展開するコンパイラマクロがある。

— Function: copy-sequence type sequence

type 型の新たなシーケンスを返す。それはsequenceと等しい要素を持つ。

— Function: first-elt sequence

シーケンスの第一要素を返す。もし sequence がシーケンスでなかったり、空であればエラーを通知する。

— Function: (setf first-elt)

シーケンスの第一要素に値をセットする。もし sequence が空だったり、シーケンスでなかったり、シーケンスに入れられないならばエラーを通知する。

— Function: last-elt sequence

シーケンスの最後の要素を返す。 sequence が真のシーケンスでなかったり、空のリストであれば type-error を返す。

— Function: (setf last-elt)

シーケンスの最後の要素に値をセットする。もし sequence が空だったり、シーケンスでなかったり、シーケンスに入れられないならばエラーを通知する。

— Function: starts-with object sequence &key test key

もし sequence の第一要素が objectEQL ならば真を返す。もし sequence がシーケンスでなかったり、空なら nil を返す。

— Function: starts-with-subseq prefix sequence &rest args &key return-suffix &allow-other-keys

sequence のはじめの要素がそれぞれ test のもとで prefix の各要素と等しいかを判定する。もし return-suffixt ならば、関数は第二の返り値として prefix と一致した後の配列を返す。

— Function: ends-with object sequence &key test key

sequence の最後の要素が objectEQL であれば真を返す。もし sequence がシーケンスでなかったり、空なら nil を返す。もし sequence がプロパーなシーケンスでなければエラーを通知する。

— Function: ends-with-subseq suffix sequence &key test

sequencesuffix で終わるかテストする。言い換えれば、 sequence の最後の (length SUFFIX) 個の要素が suffixEQUAL なら真を返す。

— Function: map-combinations function sequence &key start end length copy

startend によって区切られた サブシーケンスから構成しうる、長さ length の組み合わせのそれぞれに対して function を呼び出す。start はデフォルトで0、 end はデフォルトで sequence の長さ、length はデフォルトでサブシーケンスの長さである。(だから、lengthが指定されなければ、可能な組み合わせはたった一つ、サブシーケンスそのものである)もし copy が真なら(それがデフォルトだが)、それぞれの組み合わせのために新たな記憶領域が確保される。

If copy is false all combinations are eq to each other, in which case consequences are specified if a combination is modified by function.

— Function: map-derangements function sequence &key start end copy

start から end で定義される sequence のサブシーケンスの、それぞれの撹乱順列にたいして function が呼ばれる。撹乱順列 とは、 sequence のいずれの要素も元の位置にない順列のこと。sequence は変更されないが、それぞれの撹乱順列は互いに EQ である。撹乱順列あるいは sequence を、呼び出された関数が変更した場合の動作は未定義。

— Function: map-permutations function sequence &key start end length copy

start から end で定義される sequence のサブシーケンスから構成可能な長さ length の順列に対してfunction を呼び出す。start はデフォルトで0、 end はデフォルトで sequence の長さ、 length はデフォルトでサブシーケンスの長さである。

Macro Writing(マクロを書く)

— Macro: once-only specs &body forms

それぞれの初期化フォームが一度だけ評価されることを保証するため、spaces で指定されたシンボルを一時変数に再束縛して forms を評価する。

spaces は再束縛される変数の名前か、次のようなフォームでなければならない。

            (symbol initform)

spaces 中の裸のシンボルは下と等しい

            (symbol symbol)

Example:

            (defmacro cons1 (x) (once-only (x) `(cons ,x ,x)))
            (let ((y 0)) (cons1 (incf y))) => (1 . 1)

— Macro: with-gensyms names &body forms

forms の周りで、names 中のシンボルをそれぞれユニークなシンボルに束縛する。names の各要素は再束縛される変数の名前か、次のようなフォームでなければならない。

           (symbol string-designator)


names 中の裸のシンボルは下と等しい

           (symbol symbol)

文字列指定子は、ユニークな名前を生成するときに使われる gensym への引数になる。

— Macro: with-unique-names names &body forms

with-gensyms の別名。

— Function: featurep feature-expression

もし引数が *features* の状態とマッチすればt、そうでなければnilを返す。feature-expressionはリーダマクロ#+と#-に与えられるアトムあるいはリストならなんでもよい。

— Function: parse-body body &key documentation whole

?? body をパースし、残りのフォーム、宣言、ドキュメント文字列を多値で返す。ドキュメント文字列は、documentationが真であるときだけ返される。この辺から分からん。

Parses body into (values remaining-forms declarations doc-string). Documentation strings are recognized only if documentation is true. Syntax errors in body are signalled and whole is used in the signal arguments when given.

— Function: parse-ordinary-lambda-list lambda-list &key normalize allow-specializers normalize-optional normalize-keyword normalize-auxilary

?? さっぱり分からん

Parses an ordinary lambda-list, returning as multiple values:

1. Required parameters.

2. Optional parameter specifications, normalized into form:
(name init suppliedp)

3. Name of the rest parameter, or nil.

4. Keyword parameter specifications, normalized into form:
((keyword-name name) init suppliedp)

5. Boolean indicating &allow-other-keys presence.

6. &aux parameter specifications, normalized into form
(name init).

Signals a program-error is the lambda-list is malformed.

Symbols(シンボル)

— Function: ensure-symbol name &optional package

パッケージ指示子packageからアクセスできる、nameで表されるシンボルを返す。もしsymbolがすでにpackageからアクセスできるようになっていなければ
シンボルはそのパッケージにインターンされる。第二返り値は、シンボルがパッケージにあったかどうかを反映しており、internの第二返り値に相当する。

Example:

            (ensure-symbol :cons :cl) => cl:cons, :external

— Function: format-symbol package control &rest arguments

formatに文字列指定子controlと引数argumentsが渡されたかのように文字列を構成し、packagenilならアンインターンドシンボルを返し、tならカレントパッケージにインターン、そうでなければpackageで示されるパッケージにインターンする。

— Function: make-keyword name

name で示される文字列をキーワードパッケージにインターンする

— Function: make-gensym name

name が非負の整数であれば、それを使ってgensymを呼ぶ。そうでなければnameは文字列指定子でなければならない。この場合、指定された文字列が引数としてgensymに渡される。

— Function: make-gensym-list length &optional x

length 要素のシンボルのリストを返す。その要素は、それぞれ第二引数(デフォルトでは"G")を引数に make-gensym を呼び出した結果である。

— Function: symbolicate &rest things

?? 文字列あるいはシンボルの名前を連結して、カレントパッケージにシンボルを登録する。

Concatenate together the names of some strings and symbols, producing a symbol in the current package.


Arrays(配列)

— Type: array-index

?? 長さlengthの配列のインデックス(0以上length未満の整数)を表す型指定子。lengthのデフォルトは、array-dimension-limit

Type designator for an index into array of length: an integer between 0 (inclusive) and length (exclusive). length defaults to array-dimension-limit.

— Type: array-length

?? 長さlengthの配列の次元(0以上length以下の整数)を表す型指定子。lengthのデフォルトは、array-dimension-limit.

Type designator for a dimension of an array of length: an integer between 0 (inclusive) and length (inclusive). length defaults to array-dimension-limit.

— Function: copy-array array &key element-type fill-pointer adjustable

?? キーワード引数で上書きされない限り、同じフィルポインタと連結可能性を持つ array の非表示コピーを返す。効率は実装の adjust-array に依存する。大体の場合、特別な目的を持つコピー関数の方が効率がよい。

Returns an undisplaced copy of array, with same fill-pointer and adjustability (if any) as the original, unless overridden by the keyword arguments. Performance depends on efficiency of general adjust-array in the host lisp -- for most cases a special purpose copying function is likely to perform better.

Types(型)

— Type: string-designator

文字列指定子型。文字列指定子とは、文字列、シンボル、あるいは文字のこと。

— Macro: coercef place type-spec env

coerce のモディファイマクロ

— Function: of-type type

一引数の関数を返す。その関数は、引数が type 型ならば真を返す。

— Function: type= type1 type2

?? 第一返り値がtならば、type1type2は同じ型である。そして、第二返り値が真ならば、型の等しさは確定的に明らかである。第一返り値がnilで第二返り値がtならば型は等しくない。

Returns a primary value of t is type1 and type2 are the same type, and a secondary value that is true is the type equality could be reliably determined: primary value of nil and secondary value of t indicates that the types are not equivalent.

Numbers(数)

— Macro: maxf place &rest numbers env

max のモディファイマクロ。第一引数で示される場所に、その場所にあった値および numbers の最大値をセットする。

— Macro: minf place &rest numbers env

min のモディファイマクロ。第一引数で示される場所に、その場所にあった値および numbers の最小値をセットする。

— Function: binomial-coefficient n k

binomial coefficient (二項係数) n k 、あるいは n 個から k 個を選ぶ組み合わせの数。nk 以上でなければならない。


— Function: count-permutations n &optional k

長さ n の順列から長さ k の順列を作る組み合わせの数を返す。kのデフォルトはnである。

— Function: clamp number min max

numbermin 以上 max 以下にとどめる。 numbermin 以下ならば min を、max 以上なら max を、そうでなければ number を返す。

— Function: lerp v a b

ab の間の、補完係数 v を使った線形補間を返す。

— Function: factorial n

非負の整数 n の階乗を返す。

— Function: subfactorial n

非負の整数 nsubfactorial を返す。

note: subfactorial とは、 n の階乗と自然対数の除を超えない最大の自然数

— Function: gaussian-random &optional min max

2つの正規乱数を第一・第二返り値として返す。 mixmax によって制限をつけることもできる。正規乱数は 0.0d0 を平均とするの正規分布に従う。

— Function: iota n &key start step

?? start から始まり、 step ずつ増加する長さ n のリストを返す。 start のデフォルトは0、stepのデフォルトは1である。

Return a list of n numbers, starting from start (with numeric contagion from step applied), each consequtive number being the sum of the previous one and step. start defaults to 0 and step to 1.

Examples:

            (iota 4)                      => (0 1 2 3 4)
            (iota 3 :start 1 :step 1.0)   => (1.0 2.0 3.0)
            (iota 3 :start -1 :step -1/2) => (-1 -3/2 -2)

— Function: map-iota function n &key start step

?? start から始まり、 step ずつ増加する長さ n のリストの各要素に function を適用した結果のを返す。 start のデフォルトは0、stepのデフォルトは1である。

Calls function with n numbers, starting from start (with numeric contagion from step applied), each consequtive number being the sum of the previous one and step. start defaults to 0 and step to 1. Returns n.

Examples:

            (map-iota #'print 3 :start 1 :step 1.0) => 3
              ;;; 1.0
              ;;; 2.0
              ;;; 3.0

— Function: mean sample

sample の mean(平均)を返す。 sample は数字のシーケンスでなければならない。

— Function: median sample

sample の median(中央値)を返す。 sample は数値のシーケンスでなければならない。

— Function: variance sample &key biased

sample のvariance(分散)。 biased が真ならば biased variance を返す(これがデフォルト)。
biased が偽ならば unbiased estimator of variance を返す。
sample は数字のシーケンスでなければならない。

— Function: standard-deviation sample &key biased

sample の standard deviation (標準偏差)。 biased が真ならば biased standard deviation を返す(これがデフォルト)。biased が偽ならば、 unbiased estimator for variance の平方根を返す。(これと unbiased estimator for standard deviation は同じではない)sample は数字のシーケンスでなければならない。