Skip to content

Instantly share code, notes, and snippets.

@patham9
Created August 2, 2023 00:10
Show Gist options
  • Save patham9/b0f9be3a82ed90b6d45cd17311fdc248 to your computer and use it in GitHub Desktop.
Save patham9/b0f9be3a82ed90b6d45cd17311fdc248 to your computer and use it in GitHub Desktop.
Logic programming
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