Last element of the list

Hi,

In the @Jana_Tuerlich post (calculate distance between several points --> calculate travelled distance) the problem is to extract the last element of the list … that leads me to some basic questions :confused: about lists and sets in KNIME.
What is the difference between a set and a list?
In the “Column expressions” node there are array functions … What is an array in KNIME?
The array functions (like arrayLength) seems to work with both (sets and lists) but I am getting a strange result with the arraySubset function. What I am missing? What that result means?

LastOfSet.knwf (11.2 KB)

For now the best solution seems to be a python code … I can’t find a KNIME node or function (arraySubset function doesn’t work) that extracts an specific element of the list like in python.

Thank you for your patience

Hello @andrejz,

Good questions! I can give you my non-developer view (which might be wrong of course). List and Set are both Collection column types available in KNIME and difference is that Set doesn’t store duplicate values (check configuration of Create Collection Column node). There is no really “array” in KNIME or there is if you think of collection column as column holding arrays. Makes sense?

Now array functions from Column Expressions nodes are actually functions that are applicable to Collection column types (so both list and sets as you figured it out). The strange results you are getting in second Column Expressions node is because arraySubset() function returns array and you need to check Collection checkbox in node configuration to address it (a bit back and forth with array and collection terminology… :smiley:) or use arrayToString() function. Without it arrays gets represent awkwardly. Anyways here is modified workflow example:
LastOfSet_ipazin.knwf (13.9 KB)

Hope this clarifies collections, arrays, lists and sets in KNIME!

Br,
Ivan

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.