06-26-2018 02:30 AM
What is the best method of re-indexing an array for instance
I want to change an array from [a,b,c,d,...]
to an array in the following form
Solved! Go to Solution.
06-26-2018 03:01 AM
06-26-2018 03:14 AM
06-26-2018 02:02 PM - edited 06-26-2018 02:03 PM
Of course Artem's solution is most universal and works for most datatypes (numerics, strings, etc. interleaving with other values, etc.).
Just for fun, here are two more versions for numeric arrays only:
This one is potentially dangerous (if the input contains NANs, INFs, -INFs, etc the interleaved element will be NaN), OTOH, it's less code.
Here's a cute one. See if you figure it out 😄
06-26-2018 02:20 PM
The one that uses the typecasting is very interesting.
First you created a complex numbers a+0i, b+0i, c+0i, d+0i
then you fed the typecast type port (on top) from the real part, this will make the typecasting to real numbers. Therefore, instead of being written in complex form the real and imaginary are written successively in one column which made it a,0 b,0,c,0,d,0.
Thank you very much, I really appreciate your creativity.