LoginLogin

Array literals without string manipulation

Root / Submissions / [.]

MZ952Created:
There are definitely better ways to do this in SB, but uh:
DEF _()
 DIM N READ N
 DIM R[N],I
 FOR I=0 TO N-1 READ R[I] NEXT I
 RETURN R
END
It can be used as follows:
DIM A[0]
DATA 3, 1,2,3
A=_()
PRINTALL A
> [1,2,3]
The very first DATA value is the number of elements to be read, excluding itself. Keep in mind the function _() can only be called once, and you basically can't use any other DATA in your program unless you clean it all up with RESTORE, or READ all data in some implicit manner.

No posts yet (will you be the first?)