Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
タイトルはほとんどすべてを物語っています。
私は何かを探しています
(atleastonenonnil '(nil nil nil nil '(A B C))) => T
再帰的な方法でそれを行うことはできましたが、できませんでした。組み込み関数を使用する必要がありますか? 私は使用していますcLisp
cLisp
リストの最初の要素を処理する場合、残りはすべて再帰的に実行できます。コードは次のとおりです。
(defun at-least-one-nonnil (l) (and (not (nullp l)) (or (car l) (at-least-one-nonnil (cdr l))))))
もちろん、この単純なケースでは、すでに組み込み関数があります。
(defun at-least-one-nonnil-v2 (l) (some #'identity l))
しかし、それは再帰について学ぶのに役立ちません。