/[cells]/triple-cells/ag-utilities.lisp
ViewVC logotype

Contents of /triple-cells/ag-utilities.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sat Feb 23 01:23:45 2008 UTC (6 years, 1 month ago) by ktilton
Branch: MAIN
CVS Tags: HEAD
*** empty log message ***
1 ;; -*- mode: Lisp; Syntax: Common-Lisp; Package: triple-cells; -*-
2 ;;;
3 ;;;
4 ;;; Copyright (c) 2008 by Kenneth William Tilton.
5 ;;;
6
7
8 (in-package :3c)
9
10 ;; --- ag utils -----------------------
11
12 #+test
13 (progn
14 (make-tutorial-store)
15 (let ((s (mk-upi "a"))
16 (p (new-blank-node)))
17 (loop repeat 10
18 do (add-triple s (mk-upi (random 10)) p))
19 (index-new-triples)
20 (loop for tr in (get-triples-list :s s)
21 do (print (upi->value (predicate tr))))))
22
23 (defun triple-value (tr)
24 (when tr
25 (upi->value (object tr))))
26
27 (defun get-sp (s p)
28 #+allegrocl (get-triple :s s :p p)
29 #-allegrocl (car (get-triples-list :s s :p p)))
30
31 (defun get-spo (s p o)
32 #+allegrocl (get-triple :s s :p p :o o)
33 #-allegrocl (car (get-triples-list :s s :p p :o o)))
34
35 (defun get-sp-value (s p)
36 (triple-value (get-sp s p)))
37
38 (defun mk-upi (v)
39 (typecase v
40 (string (literal v))
41 (symbol (mk-upi (symbol-name v)))
42 (integer (value->upi v :long))
43 (future-part v)
44 (otherwise (if (upip v) v
45 (break "not upi-able ~a ~a" (type-of v) v)))))
46
47
48 (defun ensure-triple (s p o)
49 (unless (get-spo s p o)
50 (add-triple s p o)))
51

  ViewVC Help
Powered by ViewVC 1.1.5