Created
September 9, 2015 18:02
-
-
Save ebellani/157c75ccca2470cf128d to your computer and use it in GitHub Desktop.
datalog doubt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require datalog) | |
(define corporate-chain | |
(make-theory)) | |
(datalog corporate-chain | |
;; shareholders | |
(! (shareholder "Jorge" "pf")) | |
(! (shareholder "Bob" "pf")) | |
(! (shareholder "Googly" "pj")) | |
(! (shareholder "Megasoft" "pj")) | |
;; ownership | |
(! (owns-a-share "Jorge" "Construction SA" 60.8 "shareholder")) | |
(! (owns-a-share "Bob" "Construction SA" 39.2 "shareholder")) | |
(! (owns-a-share "Googly" "Toys SA" 100 "shareholder"))) | |
;; should return every owner who owns more than 50% | |
(datalog corporate-chain | |
(! (:- (major-stockholder SHAREHOLDER) | |
(owns-a-share SHAREHOLDER COMPANY PERCENT RELATIONSHIP) | |
(> PERCENT 50) | |
)) | |
(? (major-stockholder X))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment