#:g1: ClojureでL-99 (P03 K番目の要素)

Posted 2008-09-21 12:35:00 GMT

-(http://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html)

;; P03 (*) Find the K'th element of a list.

(defn element-at [coll pos] (loop [coll coll, pos pos] (if (>= 1 pos) (first coll) (recur (rest coll) (- pos 1)))))

(element-at "いろはにほ" 3)

;=> \は


comments powered by Disqus