#lang scheme
(define consecutive?
(lambda(a b c)
((cond [(and (= (- b a) 1) (or (= (- c b) 1) (= (- a c) 1))) "true"]
[(and (= (- a b) 1) (or (= (- c a) 1) (= (- b c) 1))) "true"]
[(and (= (- c a) 1) (or (= (- a b) 1) (= (- b c) 1))) "true"]
[(and (= (- a c) 1) (or (= (- c b) 1) (= (- b a) 1))) "true"] …Run Code Online (Sandbox Code Playgroud) 我正在和The Little Schemer一起学习Scheme,遇到了一个奇怪的麻烦.这是我的代码:
(define rember
(lambda (a lat)
((if (null? lat)
'()
(cond
((eq? a (car lat)) (cdr lat))
(else (rember a (cdr lat))))))))
(rember 'aaa '(bbb aaa))
Run Code Online (Sandbox Code Playgroud)
我在教科书中使用了"if"而不是"cond".从尾递归返回时,它显示以下错误:
application: not a procedure;
expected a procedure that can be applied to arguments
given: '()
arguments...: [none]
Run Code Online (Sandbox Code Playgroud)
我想这是因为它将if语句中的'()视为函数,尾递归的返回值作为参数.但由于这本书没有给我这么多关于语言的细节,你能否为我解释一下这个?(例如,这实际上是某种语言特征吗?在这段代码中我有什么办法可以坚持"if"吗?我什么时候可以安全地使用"if"?)
谢谢.
我在Ubuntu Raring上使用SLIME / SBCL / Emacs和Quicklisp。我有下面定义的功能。我想将其添加到我的Lisp库的顶级.lisp文件中,即彼此依赖的一个文件,这样我就可以在我用库编写的所有函数中使用它,只需添加(update-swank)一个函数即可,而不必添加下面的整个功能,以及使用该功能的每段代码。
(defun update-swank ()
"Grabs SWANK connections and tells it to handle requests.
Call this every loop in the main loop of your program"
(continuable
(let ((connection (or swank::*emacs-connection*
(swank::default-connection))))
(when connection
(swank::handle-requests connection t)))))
Run Code Online (Sandbox Code Playgroud)
当我这样做并重新启动emacs时,由于我的asdf:load-op.sbclrc文件中包含,因此在加载过程中加载了我的库,我得到了
READ error during COMPILE-FILE:
;
; Package SWANK does not exist.
Run Code Online (Sandbox Code Playgroud)
在劣等的Lisp中,由于库未加载,SLIME被卡住了轮询,因为在我当前的设置中,SLIME / SBCL update-swank在加载其中的.lisp文件时不知道到底是什么。我尝试添加(in-package :swank)到其中的文件update-swank中,但是得到了
The name "SWANK" does not designate any package.
Run Code Online (Sandbox Code Playgroud)
在emacs启动时加载我的库时,性能下降。
我搜索了CEPL(从https://github.com/cbaggers/cepl/blob/master/cepl-utils.lisp获得更新更新),然后复制了CEPL的创建者所做的工作并将函数导出到了我的包中.lisp。我确保像他在cepl-utils的第20行上一样添加了该功能,在这里https://github.com/cbaggers/cepl/blob/master/cepl-utils.lisp ...... …
你能帮我解决一下我的代码,我不明白为什么它没有返回我的wireList,它只是返回NIL
(defun table-wires-position(inputTable inputPosition)
(let ((wireList () ))
(dolist (x (table-wires inputTable) wireList)
(if (or (equal-position-p (wire-OriginCoin x) inputPosition)
(equal-position-p (wire-destinCoin x) inputPosition))
(cons x wireList)))))
Run Code Online (Sandbox Code Playgroud) 我们如何在 Jena 中定义类和子类并将它们添加为其他资源的类型?我使用 Java、Jena 和 RDF/XML 表示法。我想创建类似的东西:
<rdfs:Class rdf:about="http://www.help.me/NS/Classname"/>
<rdfs:Class rdf:about="http://www.help.me/NS/Subclassname">
<rdfs:subClassOf rdf:resource="http://www.help.me/NS/Classname"/>
</rdfs:Class>
Run Code Online (Sandbox Code Playgroud)
之后:将资源链接到子类:
<rdf:Description rdf:about="http://www.help.me/NS/NewResource">
<rdf:type rdf:resource="http://www.help.me/NS/Subclassname"/>
...
</rdf:Description>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我找到了如何定义一个类:
model.createResource("http://www.help.me/NS/", RDFS.Class);
Run Code Online (Sandbox Code Playgroud) 我想从Java(特别是Jena和ARQ)创建SPARQL查询。我想让可能对SPARQL一无所知的用户仅通过写(例如,在Eclipse的控制台中)他想搜索的词来进行查询。以下代码提供了我要寻找的示例。如何将字符串word插入查询中?
String word="someThingToFind"; // a variable entered by the user who want to request my data
String queryString =
"Select ?a ?b"+
" Where { ...."+
" Filter (regex(?a = ".concat(word)+ "))"+// word is the String variable
" }";
Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
QueryExecution qe = QueryExecutionFactory.create(query, model);
ResultSet results = qe.execSelect();
ResultSetFormatter.out(System.out, results, query);
qe.close();
Run Code Online (Sandbox Code Playgroud) 是的,我正在为一位朋友在网站上工作,而我正试图让旋转木马正常工作.但是,看似无论我尝试什么.
标记:http://pastebin.com/PjftpnJx
文件夹结构:

Owl CSS文件的扩展名更改为.less并包含在我编译成CSS的主LESS文件中,这意味着文件存在.
我有一个简单的问题。当我在DBpedia SPARQL端点上运行此查询时,我得到5个电影URI的列表:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
select ?film {
?film rdf:type <http://schema.org/Movie>.
}
limit 5
Run Code Online (Sandbox Code Playgroud)
我正在尝试访问列表中每部电影的所有谓词和对象。我试过了,但是没有用。
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
select ?film ?p ?o {
?film rdf:type <http://schema.org/Movie>;
?p ?o.
}
group by ?film
limit 5
Run Code Online (Sandbox Code Playgroud)
有什么建议吗?
如何在Lisp中将数字从某个基数转换为基数10?是否有任何defaut功能可以做到这一点,如果不是我怎么能补充该功能?
rdf ×4
common-lisp ×3
java ×3
jena ×3
lisp ×3
racket ×2
scheme ×2
sparql ×2
base ×1
dbpedia ×1
html ×1
javascript ×1
jquery ×1
owl-carousel ×1
rdfs ×1
semantic-web ×1
semantics ×1
slime ×1
swank ×1