Clojure中的功能

问题描述 投票:0回答:1

我有一个任务来创建一个赋予列表功能的函数。

列表的输出(1 2 3)应为:

1
2
3
1 2
1 3
2 3
1 2 3

我尝试了此辅助函数

(defn print-powerset-helper [lst] (if(not(empty? lst)) (do (println(first lst)) (print-lst (rest lst))))) 

这给了我

1 
2 
3
nil

此输出。

我也很讨厌这个功能:

(defn print-powerset [lst] (if (not (empty? lst)) (do (apply println lst (print-lst lst)))))

输出:

1
2
3
(1 2 3)
nil

我想摆脱括号,也不了解如何打印输出的中间部分。 1 2 1 3 2 3,这部分。

请任何帮助都会很好。谢谢!

list function clojure clojurescript
1个回答
0
投票
请查看documentation listed here

我认为您将开始阅读BraveClojure网站和书。

© www.soinside.com 2019 - 2024. All rights reserved.