我一直很享受Clojure core.logic,但我遇到了一堵墙.我需要能够使用数据库,无论是否使用SQL,而不是内存数据结构.当我环顾四周时,我看到了一个to-stream
功能的提及,但没有使用它的实例.
有没有人有一个将core.logic与数据库一起使用的好例子?
我在看 clojure.core函数重组:
(defn re-groups [^java.util.regex.Matcher m]
(let [gc (. m (groupCount))]
(if (zero? gc)
(. m (group))
(loop [ret [] c 0]
(if (<= c gc)
(recur (conj ret (. m (group c))) (inc c))
ret)))))
Run Code Online (Sandbox Code Playgroud)
并认为将其重写为多方法会"更好":
(defmulti re-groups (fn [^java.util.regex.Matcher m] (.groupCount m)))
(defmethod re-groups 0 [m] (.group m))
(defmethod re-groups :default [m]
(let [idxs (range (inc (.groupCount m)))]
(reduce #(conj %1 (.group m %2)) [] idxs)))
Run Code Online (Sandbox Code Playgroud)
然而,当比较我被惊讶的时候看到重写慢4倍:
clojure.core: "Elapsed time: 668.029589 msecs"
multi-method: "Elapsed time: 2632.672379 msecs" …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Clojure core.logic从地图中提取数据.这段代码按我的意愿执行:
(run 10 [q]
(fresh [?id ?type ?name]
(membero ?type [:t2 :t1])
(== q [?id ?name])
(membero {:id ?id :type ?type :name ?name}
[
{:id 1 :type :t1 :name "one"}
{:id 2 :type :t2 :name "two"}
])))
=> ([2 "two"] [1 "one"])
Run Code Online (Sandbox Code Playgroud)
但是,如果我向地图添加一些其他元素,那么它将无法匹配:
(run 10 [q]
(fresh [?id ?type ?name]
(membero ?type [:t2 :t1])
(== q [?id ?name])
(membero {:id ?id :type ?type :name ?name}
[
{:id 1 :type :t1 :name "one" :other1 :o1}
{:id 2 :type :t2 :name …
Run Code Online (Sandbox Code Playgroud) 使用Emacs 24.3.1附带的CEDET和Melpa中的ECB,我得到以下尝试ecb-activate
:
All requirements for ECB 2.40 fulfilled - Enjoy it! [2 times]
The ECB is now deactivated.
ecb-clean-up-after-activation-failure: ECB 2.40: Errors during the layout setup of ECB.
(error-type: void-variable, error-data: (ecb-examples-bufferinfo-buffer-name))
Run Code Online (Sandbox Code Playgroud)
以下是emacs pacakage经理的信息:
ecb is an installed package.
Status: Installed in `/home/Smith/.emacs.d/elpa/ecb-20131116.1319/'.
Version: 20131116.1319
Summary: a code browser for Emacs
cedet is a built-in package.
Status: Built-in.
Version: 2.0
Summary: Setup CEDET environment
Run Code Online (Sandbox Code Playgroud)
我的问题,如何让这个工作.亚力克斯奥特的欧洲央行分支似乎表明应该这样做.
以下是我想要开始工作的示例代码:
(letfn [(CONC [f] f)
(CONT [f] (str "\newline" f))]
((voodoo "CONC") "hamster"))
Run Code Online (Sandbox Code Playgroud)
是否有一些voodo会让它以仓鼠为参数调用CONC函数?也就是说,有没有办法将字符串"CONC"转换为未绑定到命名空间而不是绑定到本地绑定的函数?
编辑:
更清楚的是,这将被称为:
(map #((voodoo (:tag %)) (:value %))
[
{:tag "CONC" :value "hamster"}
{:tag "CONT" :value "gerbil"}
]
)
Run Code Online (Sandbox Code Playgroud) 使用 JQuery 数据表可以很容易地使用 AJAX 检索表的内容。我让我们能够在用户翻阅数据时隐藏或显示一列的问题。在表中有一个带有复选框的列,但并非所有行都有复选框。如果当前页面没有任何带有复选框的行,我该如何隐藏该列,并在将页面(使用数据表分页功能)用户页面(使用数据表分页功能)到包含文本框的行的页面时显示它们?
在使用test.check时,我需要一个生成器来处理一定长度的字符串.电话号码,邮政编码,社会安全号码都是这类数据的例子.虽然这些例子看起来只是数字,但我的问题一般是字符串.
当我们尝试使用org.springframework.wspring-ws作为maven项目中的依赖项时:
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws</artifactId>
<version>1.5.8</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
它没有找到.看着回购的pom就在那里,罐子也是如此,但罐子里的名字就像是spring-ws-1.5.8-all.jar
.
我的问题:首先,我如何将其用作maven pom中的依赖项?第二,为什么这个文件这样命名?
clojure ×5
ajax ×1
callback ×1
cedet ×1
datatables ×1
emacs ×1
emacs-ecb ×1
java ×1
jquery ×1
maven ×1
multimethod ×1
paging ×1
performance ×1
spring ×1
spring-ws ×1
test.check ×1
version ×1