forked from Datomic/datomic-java-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWith.java
More file actions
33 lines (27 loc) · 1021 Bytes
/
With.java
File metadata and controls
33 lines (27 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package datomic.samples;
import datomic.Peer;
import java.util.Collection;
import java.util.List;
import static datomic.Peer.query;
import static datomic.Util.list;
import static datomic.samples.PrettyPrint.print;
public class With {
public static Object incorrectHeadCount() {
return query("[:find (sum ?heads) ." +
" :in [[_ ?heads]]]", monsters);
}
public static Object correctHeadCount() {
return query("[:find (sum ?heads) ." +
" :with ?monster" +
" :in [[?monster ?heads]]]", monsters);
}
public static final Collection monsters = list(list("Cerberus", 3),
list("Medusa", 1),
list("Cyclops", 1),
list("Chimera", 1));
public static void main(String[] args) {
print(incorrectHeadCount());
print(correctHeadCount());
Peer.shutdown(true);
}
}