此函数返回列表中第" n"个位置的元素。

nth - 语法

以下是语法。

(nth lst index)

参数      -  " lst"是列表。 " index"是元素的索引位置,需要返回。

返回值  -  列表中索引位置的值。

nth - 示例

(ns clojure.examples.example
   (:gen-class))
(defn example []
   (println (nth (list 1 2,3) 0))
   (println (nth (list 1 2,3) 2)))
(example)

上面的程序产生以下输出。

1
3

参考链接

https://www.learnfk.com/clojure/clojure-lists-nth.html