[racket] Datalog: summing

From: Mark Carter (mcturra2000 at yahoo.co.uk)
Date: Mon Sep 19 05:25:44 EDT 2011

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 way of writing floats, or is that out of the question?




Posted on the users mailing list.