仅用于确保将不同的元素添加到序列中。
以下是语法。
(distinct seq1)
参数 - " seq1"是元素的顺序列表。
返回值 - 元素序列,其中仅返回不同的元素。
(ns clojure.examples.example (:gen-class)) ;; This program displays Hello Learnfk (defn Example [] (def seq1 (distinct (seq [1 1 2 2]))) (println seq1)) (Example)
上面的程序产生以下输出。
(1 2)
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)