评论:4clojure 题解 Nth Element

模拟nth函数Write a function which returns the Nth element from a sequence.(= (__ '(4 5 6 7) 2) 6)(= (__ [:a :b :c] 0) :a)(= (__ [1 2 3 4] 1) 2)(= (__ '([1 2] [3 4] [5 6]) 2) [5 6])用递归试了下可以通过(fn d [seq x] (if (> x 0) (d (rest seq) (dec [更多>>]

网友评论0 条评论)
发表评论

Copyright © 2012-2014 我的代码板 Inc. 保留所有权利。

页面耗时0.0194秒, 内存占用1.81 MB, 访问数据库8次

闽ICP备15009223号-1