[racket] Racklog: asking data from user?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Apr 12 14:38:41 EDT 2012

Using Racket predicates like that would be a very bad idea and hard to
get working as you've discovered.

I think the correct approach is to wrap the Racklog program in a
Racket program that makes queries of the *log and then asks questions
of the user afterwards and repeats the query if necessary.

I think of *log as a database that exists at an arm's reach from the
computation of import and so it shouldn't do too much work and
definitely shouldn't do IO.


On 4/12/12, Mikko Tiihonen <mikko.tiihonen at tmtiihonen.fi> wrote:
> Hi!
> I have just started to study Racket and Racklog, so this probably is a very
> elementary problem, but I haven't been able to find a satisfactory solution
> on my own, and I would be grateful for getting some pointers into the right
> direction.
> I'm trying to employ Racklog for mixed forward and backward chaining
> inference and have conducted some experimentation with it. I use a
> blackboard-like repository for facts implemented as a Racklog predicate.
> However I have not been able to figure out how I could automatically ask the
> user for missing pieces of data. When the inference engine tries
> unsuccessfully to unify a goal with the blackboard, I would like to present
> the user with a dialog asking her to input the data, which could then be
> added to the blackboard. Embedding this into Racklog predicates has turned
> out to be harder than I could imagine - probably I've just overlooked or
> misunderstood some critical piece of data in the Racklog manual.  Any help
> will be appreciated.
> Best regards,
> Mikko Tiihonen
> P.S.
> This succeeds, when tried directly:
> (define %pred
>   (%rel ()
>         (() (%== #t (equal? (read-line) "t")))))
> but when chained backwards from another predicate, no dialog is presented.

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.