此函数返回向量中第n个位置的项目。

nth - 语法

以下是语法。

(nth vec index)

参数      -  " vec"是项目的向量, "index"是需要返回的元素的索引位置。

返回值  -  向量中索引位置的值。

nth - 示例

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

上面的代码产生以下输出。

1
3

参考链接

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