Created
August 2, 2023 00:10
-
-
Save patham9/b0f9be3a82ed90b6d45cd17311fdc248 to your computer and use it in GitHub Desktop.
Logic programming
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
use hyperon::metta::*; | |
use hyperon::metta::interpreter::*; | |
fn main() { | |
let space = metta_space(" | |
(= (if True $a) $a) | |
(= (if False $a) nop) | |
(= (and True True) True) | |
(= (and True False) False) | |
(= (and False True) False) | |
(= (and False False) False) | |
(= (male herbert) True) | |
(= (male christa) False) | |
(= (parent patrick herbert) True) | |
(= (parent patrick christa) True) | |
(= (father $1 $2) (and (parent $1 $2) (male $2))) | |
(= (son $1 $2) (father $2 $1)) | |
"); | |
println!("{:?}", interpret(&space, &metta_atom("(if (son herbert $1) (print $1))"))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment