Hi,
I have a rule like:

rule "Rule1"
    when
        $fact: Fact1()
        $allFacts: ArrayList() from collect(Fact1())

    then
        insert(new Fact2($allFacts.size()));
end


I want to compute $allFacts inside a function since I will use it across different rules.
This doesn't work because it is not valid Java syntax:

function int size() {
    ArrayList a = ArrayList() from collect(InQueuePredicate());
    return a.size();
}

Could I put this in a named query, and call it from a function?

Thanks!
Miguel