Clojure循环函数仅返回Nil

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

下面的函数将text变量拆分为一个长度为[[steps的字符序列。唯一的问题是我不知道如何返回结果列表,我需要为step的几个值计算其香农熵。(defn split-text [text step] (loop [i 0 result []] (when (<= (+ i step) (count text)) (recur (+ i step) (conj result (subs text i (+ i step)))))))

下面的函数将文本变量拆分为几步长的字符序列。唯一的问题是我不知道如何返回结果列表,我需要计算出它的结果...
clojure
1个回答
0
投票
您需要从循环中返回结果:
© www.soinside.com 2019 - 2024. All rights reserved.