小编S.H*_*.H.的帖子

Clojure - 分割字符串而不丢失分隔符

Clojure 是否有 Split 函数,可以将字符串拆分为包含分隔符的子字符串?像“a=b”一样,分隔符“=”返回:“a”、“=”、“b”。谢谢!

string split clojure separator

4
推荐指数
1
解决办法
966
查看次数

Clojure - recur适用于循环或let语句?

我在Clojure中有一个关于复发的问题.如果我在循环中有一个let语句,那么recur调用是否可以应用于let语句而不是循环的值?例如,在这种情况下:

(defn someFunction [listA listB]
  ("do something here...." 
      [new-listA new-listB]))

(defn anotherFunction [listA listB]
  ("do something here...." 
      [new-listA new-listB]))

(defn myFunction [firstList secondList]
  (loop [list1 (someMutation firstList)
         list2 (someMutation secondList)]
    (if (= "true" (someCondition))
      (let [[newlist1 newlist2]
           (someFunction list1 list2)] 
        (recur newlist1 newlist2))
      (anotherFunction list1 list2) )))
Run Code Online (Sandbox Code Playgroud)

是(recur newlist1 newlist2)应用于循环还是let?有没有一种方法可以跳过这个let语句并直接使用"someFunction"返回的两个值调用recur,假设我不能改变"someFunction"返回带有两个参数的向量这一事实?

recursion loops clojure let

2
推荐指数
1
解决办法
686
查看次数

标签 统计

clojure ×2

let ×1

loops ×1

recursion ×1

separator ×1

split ×1

string ×1