私はループステートメントのための特定のインデックスのリストからアイテムを取得しようとしています。この場合ラケット言語で指定されたインデックスのリストからアイテムを取得するにはどうすればよいですか?
(define decision-tree-learning
(lambda (examples attribs default)
(cond
[(empty? examples) default]
[(same-classification? examples) (caar examples)] ; returns the classification
[else (lambda()
(let ((best (choose-attribute attributes examples))
(tree (make-tree best))
(m (majority-value examples))
(i 0)
(countdown (length best)) ; starts at lengths and will decrease by 1
(let loop()
(let example-sub ; here, totally stuck now
; more stuff
(set! countdown (- countdown 1))
; more stuff
)))))])))
、best
はリストであり、私はcountdown
インデックスではその値を取得する必要があります。あなたは私を助けてくれますか?
インデックスをループして 'list-ref'を使用する代わりに、リストを直接ループするのはなぜですか? –
また、リストからランダムアクセスを行っている場合は、データの適切なコンテナタイプではない可能性があります。 Racket(と同様にScheme)は、定数時間ランダムアクセスをサポートする* vector *型を提供します。 http://docs.racket-lang.org/guide/vectors.html – dyoo
コメントありがとうございます。私はラケットラングでは本当に新しいので、私はこのすべてを感謝します。 – lu1s