Advanced query: 'Unknown function' error for trying to use a clojure.core function

Hello, to my understanding, it should be possible to use any pure function from clojure.core in the :where part of an advanced query. To my understanding, clojure.core/iterate and clojure.core/nth should for example work, but I get an error saying Unknown function.... Why is that and how could I fix it? Thank you in advance.

Welcome.

  • Short answer: Many pure functions are not supported.
  • Long answer:
    • Logseq doesn’t use clojure, but clojurescript.
      • Clojurescript doesn’t implement all the functions of clojure.
      • Queries make proper use of clojurescript only in :result-transform and in :view .
        • This is in contrast to :where , which accepts an even smaller subset of functions.
    • There is no way to properly fix this without changing the codebase.
      • There are various workarounds, depending on the exact missing function and the specific need for it.
        • If you share your specific case, we could possibly suggest a workaround for it.

Thank you for the quick and detailed answer. I am trying to figure out how to implement for-loops in queries, but I think I managed to figure it out for my case with the usage of rules.