How to do `count`
I'm stuck with a very simple problem but can't find a solution. All I want is to return the number of unique facts/records found.
Let's assume I have stored the names and sizes of images, but may have stored some of them multiple times. How can I find out how many unique images do I have. What I came up with is rather complex (group_by requires me to have an aggregation function setting something, therefore the unnecessary Count)
unique(N, Count) :-
images(N, _),
|> do fn:group_by(N),
let Count = fn:count().
query(Count) :-
unique(_, _),
|> do fn:group_by(),
let Count = fn:count().
You could use fn:collect_distinct(N) to get a list of unique values, and then take the length of that list.
We are missing fn:count_distinct(), I will add it.
Closing, please reopen if fn:count_distinct() does not address your use case.