[elephant-devel] collecting values from virtual subtree?
Joe Corneli
jcorneli at planetmath.org
Sun Apr 22 22:44:30 UTC 2007
In the discussion of how to build a "virtual subtree",
http://common-lisp.net/pipermail/elephant-devel/2007-April/000949.htm
Ian gave me a tip on how to find all Triples with a certain property:
[My recipe] will create an index 'triples-first which only indexes
triples and does so by the value of the first element. Thus you
can easily retrieve all triples with the first element eq to 5.
ELE-TESTS> (map-index (lambda (sk v pk) (print v)) (get-index my-
things 'triples-first :value 5)))
Just wanted to point out that I want to *collect* these values -- so I
wrote a function that does this:
(defun match-triples-beginning (beginning)
(let ((results (list nil)))
(map-index (lambda (k v pk)
(declare (ignore k pk))
(setq results (nconc results (list v))))
(get-index *things* 'triples-beginning)
:value beginning)
(cdr results)))
This makes me think that it would be nice to have a `mapcar'-style
function built in for mapping across an index and collecting the
results. First question is, what would such a function be called!
(Maybe just add a :collect keyword to `map-index'?)
More information about the elephant-devel
mailing list