Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Boolean has_Length and _divides

  • Loading branch information...
commit 42ff2bb305f9a9148665f5d397030f018b7905c1 1 parent 2c61274
Sanpie authored
Showing with 31 additions and 0 deletions.
  1. +4 −0 eval.ml
  2. +27 −0 examples.lang
View
4 eval.ml
@@ -197,6 +197,10 @@ let prepare_literal l = match l with
else [param_to_string (List.hd vl); "%2 = 0"]
| "_isOdd" -> if len != 1 then raise (QueryError ("Boolean predicate '_isOdd' expects one parameter."))
else [param_to_string (List.hd vl); "%2 = 1"]
+ | "_divides" -> if len != 2 then raise (QueryError ("Boolean predicate '_divides' expects two parameters."))
+ else [param_to_string (List.nth vl 1); "%";param_to_string (List.hd vl);" = 0"]
+ | "_hasLength" -> if len != 2 then raise (QueryError ("Boolean predicate '_hasLength' expects two parameters."))
+ else ["length(";param_to_string (List.hd vl);")";"=";param_to_string (List.nth vl 1)]
| _ -> raise (QueryError ("Unrecognized boolean predicate '"^x^"'."))
;;
View
27 examples.lang
@@ -483,3 +483,30 @@ R(x,y,z,2):-Q(x,y,z).
#reconnect localhost 5432 postgres postgres test_db/
#quit/
+Q(x,y,z):-Marks(x,y,z) and _divides(z,z).
+?-Q(x,y,z).
+/
+
+Q(a,b,c):-Marks(a,b,c) and _divides(2,c).
+?-Q(x,y,z).
+/
+
+Q(a,b,c):-Marks(a,b,c) and _divides(c,2).
+?-Q(x,y,z).
+/
+
+Q(x,y,z):-Marks(x,y,z) and _divides(z,z,z).
+?-Q(x,y,z).
+/
+
+Q(x,y,z):-Marks(x,y,z) and not _divides(z,z).
+?-Q(x,y,z).
+/
+
+Q(x,a,b):-Names(x,y,z) and Marks(x,a,b) and b = 75 and _hasLength(y,2).
+?-Q(x,a,b).
+/
+
+Q(x,a):-Names(x,y,z) and Marks(x,a,75) and _hasLength(y,y)..
+?-Q(x,a).
+/
Please sign in to comment.
Something went wrong with that request. Please try again.