Automated extraction of all elements out of a nested array into ONE new array

20 views
Skip to first unread message

Peter Stumpf

unread,
Feb 6, 2026, 1:01:38 PM (9 days ago) Feb 6
to JaamSim Users Discussion Group
Dear Harry

is there any possibilty to extract all elements of a nested array, let's say an array with 4 arrays of each a lenght of 3 elements, in an -in an automated way- into one other array?
ExArray={ {t1,t2,t3}, {t4,t5,t6}, {t7,t8,t9}, {t10,t11,t12} }

The trivial way of course is to this do this NewArray= { ExArray(1)+ExArray(2)+ExArray(3..}

But how can one do that with the "automated counting" of the function "map" or ...?

Thanx
Peter
Nested Array-Example-Screenshot 2026-02-06 185453.png

Harry King

unread,
Feb 6, 2026, 1:14:09 PM (9 days ago) Feb 6
to JaamSim Users Discussion Group
You almost gave the solution yourself.

Use the expression   'reduce(|x,accum|(accum + x), {}, this.ExArray)'

Note that in your example, ExArray should be defined as '{ {"t1","t2","t3"}, {"t4","t5","t6"}, {"t7","t8","t9"}, {"t10","t11","t12"} }'

Harry

Peter Stumpf

unread,
Feb 8, 2026, 1:01:05 PM (7 days ago) Feb 8
to JaamSim Users Discussion Group
Dear Harry

Thank you very much!!
I thought that "reduce(|x,accum| ....)" would only work on "values", not on "arrays"!

Kind regards
Peter

Reply all
Reply to author
Forward
0 new messages