Use C:=stack(A,B)
Ooops, I should have used my glasses, indeed!
Sorry! See the reply of @lvl107 for a correct solution.
It seems like this :
Best Regards.
Loi.
Best Regards.
I guess this is just my second appraoch with differently named variables and without being ORIGIN-independent and without error checking, right? 😉
Hi Lvl107
Could you explain the logical operation of R.rows(R) ??
tks
R is a variable which ultimately contains the return value of the function (R ... Result, Return value), here its a vector.
When a variable is used in a program for the first time on the left hand side of a local assignment, it is automatically initialized with zero.
The rows(...) function, which actually returns the number of rows of a matrix, returns 0 for a scalar like 0. Therefore, the first time R[rows(R)<- ... creates a 1x1 matrix R. The next time rows(R) returns the value 1 and so with R[rows(R)<- ... another element is added to the vector R, etc.
However, the whole thing works only if the system variable ORIGIN has the value 0.
This is the reason why my function uses the expression ORIGIN+rows(R) instead of rows(R) (and I abbreviated ORIGIN in my program at the very beginning with O), so that the function also works in worksheets which use a different value for ORIGIN (many users set Origin to the value 1, so that with vectors the first element has the index 1 and not 0).
In short - R[rows(R) is a way to create a vector and add values without having to initialize the vector (which you would have to do in an extra step if you would use R <-- stack(R, ...) to add elements to the vector.
Here is a generic utility function which interleaves two vectors of arbitrary lengths. They do not necessarily have to be the same length.
File in Prime 6 format attached
EDIT: Added a slighter shorter variant
This isn't better than the others already posted, just different.
Or a small variation: