I am trying to get the current system date in Common Lisp through following function
(defun current-date-string ()
"Returns current date as a string."
(multiple-value-bind (sec min hr day mon yr dow dst-p tz)
(get-decoded-time)
(declare (ignore sec min hr dow dst-p tz))
(format nil "~A-~A-~A" yr mon day)))
Run Code Online (Sandbox Code Playgroud)
Unfortunately I am getting the current date in this format "2014-1-2". However actually I need this format "2014-01-02". Is any way we can change the format? I tried replacing nil with …
我在 RDF 知识库中有多个图
for example
<123> <hasValue> "23" <graph1>
<234> <hasValue> "47" <graph1>
<374> <hasValue> "23" <graph1>
-----------
----------
<456> <hasFeature> "50" <graph2>
<244> <hasFeature> "23" <graph2>
<123> <hasFeature> "23" <graph2>
---------------------
Run Code Online (Sandbox Code Playgroud)
现在我想运行 SPARQL 查询以获得两个图中常见的结果。
假设如果我对一张图运行以下查询,我会得到以下结果
SELECT ?subject
FROM Named <http://www.xyz.com/namespace/graph1>
WHERE {GRAPH ?graph
{?subject prefix:hasValue "23" .}}
<123>
<374>
---
---
---
Run Code Online (Sandbox Code Playgroud)
如果对 graph2 运行以下第二个查询,我会得到以下信息
SELECT ?subject
FROM Named <http://www.xyz.com/namespace/graph2>
WHERE {GRAPH ?graph
{?subject prefix:hasFeature "23" .}}
<244>
<123>
-----
Run Code Online (Sandbox Code Playgroud)
但是我想要在两个查询中都很常见的主题 <123> 。我们可以通过任何方式组合两个查询来获得两个查询中唯一的主题。提前致谢。
我试图使用给定的出生日期(表格的一串YYYY-MM-DD)计算一个人在Common Lisp中的年龄但我得到以下错误:
错误:
"2013-12-10"' is not of the expected type数字'
我的代码如下
(defun current-date-string ()
"Returns current date as a string."
(multiple-value-bind (sec min hr day mon yr dow dst-p tz)
(get-decoded-time)
(declare (ignore sec min hr dow dst-p tz))
(format nil "~A-~A-~A" yr mon day)))
(defvar (dob 1944-01-01))
(let ((age (- (current-date-string) dob))))
Run Code Online (Sandbox Code Playgroud)
谁可以在这方面给我帮助?我怀疑当前日期是字符串格式,如我的输入,但我们如何将其转换为与我的输入相同的日期格式?