当前位置: 首页 > 文档资料 > Clojure 中文教程 >

drop

优质
小牛编辑
120浏览
2023-12-01

根据需要删除的元素数量从序列中删除元素。

语法 (Syntax)

以下是语法。

(drop 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 (drop 2 seq1))
   (println seq2))
(Example)

输出 (Output)

上述程序产生以下输出。

(3 2 1)