Re: Simple Question
Paolo Amoroso <[email protected]> Fri, 17 Feb 2006 18:08:21 +0100
| Newsgroups | gmane.lisp.lisa.general |
|---|---|
| Organization | Paolo Amoroso - Milano, ITALY |
| Message-ID | <[email protected]> |
Brent Fulgham <[email protected]> writes: > How do I "query" my assertions, as I might with a standard Prolog- > style database. [...] > Welcome to OpenMCL Version 1.0 (DarwinPPC32)! [...] > ? (facts) > #<FACT F-0, HOBBIT, CF is 0.000 ; ((AGE 100) (NAME FRODO))> > #<FACT F-1, HOBBIT, CF is 0.000 ; ((AGE 200) (NAME BILBO))> [...] > ? (retrieve (?x) > (?x (hobbit (name ?name)))) > ;Compiler warnings : > ; Unused lexical variable #:G30, in an anonymous lambda form. > (((?X . #<HOBBIT #x844F246>)) ((?X . #<HOBBIT #x84397BE>))) The query works for me with CMUCL under Linux. It returns: (((?X . #<HOBBIT {594097F5}>)) ((?X . #<HOBBIT {593FA3B5}>))) This may be an OpenMCL issue. > Fine -- but how can I display this data? For example, how can I > construct a rule that lists all hobbits who are over 100? Or even You may try something like this: (defrule old-hobbit () (?h (hobbit (age ?age (> ?age 100)))) => (format t "~&Found: ~A~%" ?h)) which returns: Found: #<FACT F-2, HOBBIT, CF is 0.000 ; ((AGE 200) (NAME BILBO))> > iterate over the values to display them? > > I think I can do so using "with-simple-query", but a few examples > might help. WITH-SIMPLE-QUERY is probably the right way, but I also don't know how it works and would appreciate an example as well. Paolo -- Lisp Propulsion Laboratory log - http://www.paoloamoroso.it/log ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642