% Function EVERY, SOME, NOTEVERY, NOTANY
Function EVERY, SOME, NOTEVERY, NOTANY
every predicate &rest sequence+ => generalized-boolean
some predicate &rest sequence+ => result
notevery predicate &rest sequence+ => generalized-boolean
notany predicate &rest sequence+ => generalized-boolean
predicate - sequenceの数だけ引数を受け取る関数指定子
sequences - シーケンス
result - オブジェクト
generalized-boolean - generalized-boolean
every、some、notevery、notanyは、
引数predicateがsequenceの要素を満たすかどうかをテストします。
predicateの最初の引数は最初のsequenceの要素であり、
後続の引数は後続のシーケンスの要素です。
predicateは、最初は各sequenceのインデックス0番目の要素で呼び出され、 そのあと可能であればインデックス1番目の要素で呼ばれ、 以下同様に実行し、終了の基準が満たされるか、 もっとも短いsequenceの終わりに到達するときまで続けられます。
everyは、predicateのどれかがfalseを返却したら、
すぐにfalseを返却します。
もしsequenceの終わりに到達したら、everyはtrueを返却します。
したがってeveryは、すべてのpredicateがtrueを返却したときのみ、
trueを返却します。
someは、predicateの実行によって返却された
最初の非nilを値を返却します。
もしpredicateの実行がtrueを返却することなく
sequenceの終わりに到達したら、
someはfalseを返却します。
したがってsomeは、
もしどれかのpredicateの実行がtrueを返却したら、
trueを返却します。
notanyは、predicateのどれかがtrueを返却したら、
すぐにfalseを返却します。
もしsequenceの終わりに到達したら、notanyはtrueを返却します。
したがってnotanyは、どのpredicateもtrueを返却しない場合にのみ、
trueを返却します。
noteveryは、predicateのどれかがfalseを返却したら、
すぐにtrueを返却します。
もしsequenceの終わりに到達したら、noteveryはfalseを返却します。
したがってnoteveryは、すべてのpredicateがtrueを返却しない場合にのみ、
trueを返却します。
(every #'characterp "abc") => true
(some #'= '(1 2 3 4 5) '(5 4 3 2 1)) => true
(notevery #'< '(1 2 3 4) '(5 6 7 8) '(9 10 11 12)) => false
(notany #'> '(1 2 3 4) '(5 6 7 8) '(9 10 11 12)) => true
なし。
最初の引数がシンボルでも関数でもないときか、
続く引数のどれかが正常なシーケンスではなかったときは、
型type-errorのエラーが発生します。
他の例外が発生する可能性があり、それはpredicateの性質に依存します。
(notany predicate sequence*) == (not (some predicate sequence*))
(notevery predicate sequence*) == (not (every predicate sequence*))