目录

nth

此函数返回列表中“第n”个位置的项目。

语法 (Syntax)

以下是语法。

(nth lst index)

Parameters - 'lst'是项目列表。 'index'是元素的索引位置,需要返回。

Return Value - 列表中索引位置的值。

例子 (Example)

以下是Clojure中第n个例子。

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

输出 (Output)

上述程序产生以下输出。

1
3
↑回到顶部↑
WIKI教程 @2018