Skip to content

Instantly share code, notes, and snippets.

@qoobaa
Created December 28, 2008 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qoobaa/40339 to your computer and use it in GitHub Desktop.
Save qoobaa/40339 to your computer and use it in GitHub Desktop.
# produkt
Tuple(id: 1, parent_id: nil, value: nil, name: product)
String(id: 2, parent_id: 1, value: "IBM T41", name: name)
String(id: 3, parent_id: 1, value: "Great notebook", name: description)
Integer(id: 4, parent_id: 1, value: 500, name: price)
# kategoria
Tuple(id: 5, parent_id: nil, value: nil, name: category)
String(id: 6, parent_id: 5, value: "Computers", name: name)
# kategoria
Tuple(id: 7, parent_id: nil, value: nil, name: category)
String(id: 8, parent_id: 7, value: "Notebooks", name: name)
# asocjacje
Pointer(id: 9, parent_id: 1, value: 5, name: category)
Pointer(id: 10, parent_id: 1, value: 7, name: category)
# znajdź produkty
type == Tuple and name == product
#=> [Tuple(1)]
# dane produktu pierwszego
parent_id == 1
#=> [String(2), String(3), Integer(4), Pointer(9), Pointer(10)]
# kategorie produktu pierwszego
type == Tuple and id in values(type == Pointer and parent_id == 1 and name == category)
#=> [Tuple(5), Tuple(7)]
# nazwy kategorii
values(type == String and name == name and parent_id in ids(type == Tuple and name == category))
#=> ["Computers", "Notebooks"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment