Fri 29 Apr 2005

Awful Lisp snippet of the day

Too lazy to write Notation 3, convert it into RDF/XML, then give it to Wilbur to parse? Want an easy way to programmatically add a load of triples to your Wilbur store? Try this.
(defun add-triple-list (trips)
(let ((sub nil) (prop nil))
(dolist (x trips)
(if (listp (cadr x))
(progn
(setf sub (car x))
(dolist (y (cadr x))
(if (listp (cadr y))
(progn
(setf prop (car y))
(dolist (z (cadr y))
(db-add-triple
*db*
(triple sub prop z))))
(db-add-triple
*db*
(triple sub (car y)
(cadr y))))))
(if (listp (caddr x))
(progn
(setf sub (car x))
(setf prop (cadr x))
(dolist (y (caddr x))
(db-add-triple
*db*
(triple sub prop y))))
(db-add-triple
*db*
(triple (car x) (cadr x) (caddr x))))))))
It's horrible (and sorry about the <pre> formatting), but it means I can do this:
(add-triple-list
'((!rich:John
((!foaf:name "John Smith")
(!foaf:title "Mr")
(!foaf:lastName "Smith")
(!foaf:firstName "John")
(!foaf:knows
(!rich:FredBloggs !rich:JohnDoe))))))
which is close enough to the N3, but with fewer punctuation marks.

Great dinner tonight, if I do say so myself. It's all down to the pepper.

Posted at 2005-04-29 12:51:54 by RichardLink to Awful Lisp snippet…
Comments, trackbacks.

Bloggable IRC

After I de-cloaked on #lisp:
Xach
good lord, it's hologoat
Xach
holy, rather.
dan_b
"hologoat" sounds rather good, actually
holygoat
heh
cliini
Hologoat sounded perfectly reasonable.
dan_b
you can put your hand right through it, look
holygoat
"you can't touch this" indeed
antifuchs
lisp is like a hologoat! wild and as beautiful as you want it to be.
holygoat
heheh
dan_b
... breakdown
Things get surreal sometimes. But dan_b is quite right, “hologoat” does sound rather good.

Boy, I'm good at procrastinating! Still, the paper is on its way….

Posted at 2005-04-29 10:18:24 by RichardLink to Bloggable IRC
Comments, trackbacks.

Google
Web holygoat.co.uk
  • richard is: