Guest User

Untitled

a guest
Apr 21st, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.60 KB | None | 0 0
  1. type Subject = distinct string
  2.  
  3. #A triple is made up of a Subject, predicate and object e.g. "Bob knows alice"
  4.  
  5. register("is", string)
  6. register("knows", Subject)
  7. register("age", int64)
  8.  
  9.  
  10. tripleStore.add("Bob", "is", "male")
  11. tripleStore.add("Bob", "age", 64)
  12. tripleStore.add("Alice", "is", "female")
  13. tripleStore.add("Bob", "knows", "Alice")
  14.  
  15.  
  16. tripleStore.queryAll("Bob", "Knows") -> @["Alice"]
  17. tripleStore.query("Alice", "age") -> Optional#empty
  18. tripleStore.queryAll("Alice", "age") -> @[]
  19.  
  20.  
  21. #this shouldn't compile as hate has not been registered
  22. tripleStore.add("Bob", "Hates", "Alice")
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment