0

I am working with a fairly straightforward To-Do database. It has a hierarchical tree-like structure. Each entity is a block; every block as a children attribute for all its children, and a checked attribute. So a simple example would be:

5 :block/children 6 5 :block/children 7 6 :block/checked 1 7 :block/checked 0 ... 

I'd like to query all the blocks, for which all subtasks are completed. In the example above block 5 would not qualify, since it has one unchecked child 7.

I wrote many variants that essentially boiled down to this:

[:find ?ag :where [?ag :block/children ?child] (not [?child :block/checked 0]) ] 

This doesn't work, because it returns all the tasks that have any checked subtasks. Can someone guide me in how I can phrase this as a "for all children, make sure the predicate is correct"?

Thanks!

1 Answer 1

1

Perhaps overkill for this tiny example, but "Union-Find" will handle this and more. I do not use your applications but it here is a Prolog implementation.

https://www.swi-prolog.org/pack/file_details/union_find/README.md

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.