目录

take-last

从序列中获取最后一个元素列表。

语法 (Syntax)

以下是语法。

(take-last num seq1)

Parameters - 'seq1'是元素的序列列表。 'num'是从末尾开始需要包含在序列中的元素数。

Return Value - 包含仅包含元素结尾数的新元素序列。

例子 (Example)

以下是Clojure中的最后一个例子。

(ns clojure.examples.example
   (:gen-class))
;; This program displays Hello World
(defn Example []
   (def seq1 (seq [5 4 3 2 1]))
   (def seq2 (take-last 2 seq1))
   (println seq2))
(Example)

输出 (Output)

上述程序产生以下输出。

(2 1)
↑回到顶部↑
WIKI教程 @2018