Re: [racket] Datalog: summing

2011-09-19 Thread Wojciech Kaczmarek
Some errata below.. On Mon, Sep 19, 2011 at 14:55, Wojciech Kaczmarek wrote: > Just for the record: > > If you'd need to stay in the "Prolog" world with your summing, for example > in order to use summing result in another predicate, here's the Racklog > version: > I see I stated the above in a

Re: [racket] Datalog: summing

2011-09-19 Thread Wojciech Kaczmarek
Just for the record: If you'd need to stay in the "Prolog" world with your summing, for example in order to use summing result in another predicate, here's the Racklog version: (define %sum (%rel (x y xs acc) [('[] acc) (%= 0 acc)] [((cons x xs) acc) (%sum xs y) (%is acc (+ x y))])) Y

Re: [racket] Datalog: summing

2011-09-19 Thread Wojciech Kaczmarek
In typical Prolog the simplest way would be to use aggregate: http://www.swi-prolog.org/pldoc/doc_for?object=section(2,'A.1',swi('/doc/Manual/aggregate.html')) In Racklog you can simply use bag-of

[racket] Datalog: summing

2011-09-19 Thread Mark Carter
How do I create summing rules? Suppose I have the following facts: post(cash, 26) . post(cash, -16) . post(cash, 50) . post(beer, 20) . How do I create a rule "bal" bal(X, ???) such that the ??? gives me the sum of the second arguments in post satisfying the first argument X? Also, is there a