09-24-2023, 01:05 PM
Yes, there is an archived thread on the subject but that thread only describes literal valued of known length.
My problem is lightly different: I have a vector V of unknown length (including 0) and want to append value E.
I could use a list as well for my purpose but can't get that to work as well. Start would be the the empty vector or list which I could not get to work either. I always hat to add a dummy element and delete that dummy element it later.
Is there a way to make this work without any hacks like dummy elements and one line/row matrix? Which is what I currently do. But I would like for something more elegant.
What I tried and didn't work:
My problem is lightly different: I have a vector V of unknown length (including 0) and want to append value E.
I could use a list as well for my purpose but can't get that to work as well. Start would be the the empty vector or list which I could not get to work either. I always hat to add a dummy element and delete that dummy element it later.
Is there a way to make this work without any hacks like dummy elements and one line/row matrix? Which is what I currently do. But I would like for something more elegant.
What I tried and didn't work:
Code:
EXPORT …
BEGIN
LOCAL Retval := {};
FOR …
LOCAL Z0 := …
APPEND (Retval, Z0);
END;
RETURN Retval;
END;
Code:
EXPORT …
BEGIN
LOCAL Retval := [];
FOR …
LOCAL Z0 := …
APPEND (Retval, Z0);
END;
RETURN Retval;
END;
This works but is not very elegant:
Code:
EXPORT …
BEGIN
LOCAL Retval := [[0]];
FOR …
LOCAL Z0 := …
ADDCOL (Retval, [Z0], rowDim (Retval) + 1);
END;
DELCOL (Retval, 1);
RETURN Retval[1];
END;