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.
find記号のリストと数値を受け取り、リストの n 番目の記号を返す関数をどのように設計しますか?
find
私は出力がこれになると思います
(find (list 'a 'b 'c 'd) 3)
した
(find (list 'a 'b 'c 'd 'e 'f) 4)
'e
私を混乱させず、初心者を使って理解しやすい簡単な方法はありますか?
関数はすでに存在し、標準であり、次のように呼ばれlist-refます:
list-ref
(list-ref (list 'a 'b 'c 'd 'e 'f) 4) => 'e
ドキュメントから:
list-refpos の位置にある lst の要素を返します。ここで、リストの最初の要素は位置 0 です。リストの要素が pos 以下の場合、exn:fail:contract 例外が発生します。