Skip to content

Instantly share code, notes, and snippets.

@refset
Last active January 1, 2023 17:27
Show Gist options
  • Save refset/57a910e2b746332ec7a0a31886f57cfb to your computer and use it in GitHub Desktop.
Save refset/57a910e2b746332ec7a0a31886f57cfb to your computer and use it in GitHub Desktop.
better-tree-depth.clj
{:find [(pull hollywood [{:tmdb/type {:person [:tmdb.person/name]
:movie [:tmdb.movie/title]}}])]
:where [[kevin :tmdb.person/name "Kevin Bacon"]
(related-to kevin 2 hollywood depth)]
:rules [[(related-to [e d] e2 d*)
(rrelated-to e d e2 rd*)
[(- d rd*) d*]]
[(rrelated-to [e d] e2 d*)
[(> d 0)]
[(dec d) d*]
[credit :tmdb.person/id e]
[credit :tmdb.movie/id e2]]
[(rrelated-to [e d] e2 d**)
[(> d 0)]
[(dec d) d*]
[credit :tmdb.person/id e]
[credit :tmdb.movie/id intermediate]
(rrelated-to intermediate d* e2 d**)]]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment