WIP.
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala
index e314cba..30b8eda 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala
@@ -30,6 +30,7 @@
import java.time.{LocalDate, LocalTime}
import java.util
import java.util.{Calendar, Collections, Collection => JColl, List => JList, Map => JMap}
+
import scala.jdk.CollectionConverters.{CollectionHasAsScala, IterableHasAsJava}
trait NCIdlCompilerBase {
@@ -684,7 +685,7 @@
val jl = new util.ArrayList[Object]()
var z = 0
- dump.foreach { x =>
+ dump.toSeq.reverse.foreach { x =>
val Z(v, n) = x()
z += n
@@ -870,7 +871,10 @@
stack.push(() => {
val Z(v, n) = x()
- val jl = toList(v).asScala.toSeq.distinct.asJava
+ val jl = new util.ArrayList[Object]()
+
+ for (d <- toList(v).asScala.toSeq.distinct)
+ jl.add(d.asInstanceOf[Object])
Z(jl, n)
})
@@ -882,7 +886,12 @@
stack.push(() => {
val (lst1, lst2, n) = extract2(x1, x2)
- Z((toList(lst1).asScala ++ toList(lst2).asScala).asJava, n)
+ val jl = new util.ArrayList[Object]()
+
+ for (d <- toList(lst1).asScala ++ toList(lst2).asScala)
+ jl.add(d.asInstanceOf[Object])
+
+ Z(jl, n)
})
}
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCollections.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCollections.scala
index 45e42b6..583383a 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCollections.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCollections.scala
@@ -44,7 +44,10 @@
"has_any(list('1', '2', '3'), list('10', '20', '30')) == false",
"has_all(list('1', '2', '3'), list('1', '20', '30')) == false",
"has_all(list('1', '2', '3'), list('1', '2', '3')) == true",
+ "size(list()) == 0",
+ "list(1, 2, 3) == list(1, 2, 3)",
"first(list(1, 2, 3)) == 1",
+ "get(list(1, 2, 3), 0) == 1",
"@lst = list(1, 2, 3) first(reverse(@lst)) == last(@lst)",
"last(list(1, 2, 3)) == 3",
"is_empty(list()) == true",
@@ -62,10 +65,10 @@
"count(list()) == 0",
s"keys(json('$js')) == list('k1')",
s"values(json('$js')) == list('v1')",
- "distinct(list(1, 2, 3, 3, 2)) == list(1, 2, 3)",
+ "sort(distinct(list(1, 2, 3, 3, 2))) == sort(list(1, 2, 3))",
"distinct(list(1.0, 2.0, 3.0, 3.0, 2.0)) == list(1.0, 2.0, 3.0)",
"distinct(list('1', '2', '3', '3', '2')) == list('1', '2', '3')",
- "concat(list(1, 2, 3), list(1, 2, 3)) == list(1, 2, 3, 1, 2, 3)",
+ "sort(concat(list(1, 2, 3), list(1, 2, 3))) == sort(list(1, 2, 3, 1, 2, 3))",
"concat(list(1, 2, 3), list()) == list(1, 2, 3)",
"concat(list(), list()) == list()",
"concat(list(1, 2), list(3.0)) == list(1, 2, 3.0)"