How to generate a list of integers from two given boundaries?

Hello all,

I’m new to KNIME and currently struggling with this problem:

I want to generate a list of integers determined by the following scenario.

E.g. for the first row I want the cell ‘range’ to hold a list of integers following the pattern [27, 28, 29, … , 49, 50]. How would I achieve this using mainly onboard nodes?

Thanks for your suggestions!

Maybe it’s a bit complicated, but it shows a lot of functionality of KNIME :slight_smile:

Let me know if you have any questions.

3 Likes

Hi @mam

Welcome to KNIME Forum.
The nice thing about KNIME, there is always more than 1 solution. See this wf
generate a list from 2 given boundaries.knwf (43.3 KB)

Less nodes needed :slight_smile:

gr. Hans

3 Likes

Hi @mam , you may also be intetested in the various ideas in this thread…

4 Likes

Thanks a lot for all your thoghts and input! (:

In the meantime I came up with a solution by myself using a Java Snippet. However, while I don’t like the nature of this (little counterintentional from KNIME’s idea of “What you see is what you get.”) I like that it can be done using only one node.

I’ll pay closer attention to the proposed ideas later today. For other people struggling here’s my solution:

1 Like

Nice solution! I was hoping someone else would jump on and provide an alternative (reminds me of code golf (KNIME golf?)). But yours pays the overhead of loop resetting for every row, which I think is somewhat expensive.

In fact, I just timed it and that’s the execution time on 10000 random dummy rows:

Solution Execution Time (ms)
mam 53
hotzm 2789
HansS 26442

The Java Snippet really pays off in this easy task in terms of runtime.

Benchmark workflow is here:

2 Likes

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