! Array utils

Post Reply
User avatar
Dutchman
Posts: 148
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

! Array utils

Post by Dutchman » Wed Nov 20, 2019 11:53 am

! Array utils {/Extensions/Arrays/! Array utils}
Functions to return variables or a list from a part of the input list

Code: Select all

' {/Extensions/Arrays/! Array utils} 
[ data transfer from arrays ]
'
[–––––––––––––––––––––––– Functions ––––––––––––––––––––––––
LoadN(A(),N,i)
returns N values from A() starting with A(i)
0<N<=10
–––
LoadList(A(),N,i)
returns list with N values from A(), starting with A(i)
–––
End of function descriptions –––––––––––]
'
[–––––––––––––––––––––– Implementation ––––––––––––––––––––––]
DEF LoadN(A(),N,i) ' by Ton Nillesen, November 2019
ON N GOTO 1,2,3,4,5,6,7,8,9
1: RETURN a(i)
2: RETURN a(i) a(i+1)
3: RETURN a(i) a(i+1) a(i+2)
4: RETURN a(i) a(i+1) a(i+2) a(i+3)
5: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4)
6: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5)
7: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6)
8: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6) a(i+7)
9: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6) a(i+7) a(i+8)
10: RETURN a(i) a(i+1) a(i+2) a(i+3) a(i+4) a(i+5) a(i+6) a(i+7) a(i+8) a(i+9)
END DEF
'
DEF LoadList(A(),N,i) ' by Ton Nillesen, November 2019
DIM X()
FOR j=0 TO N-1 : x+A(i+j) : NEXT i
RETURN x
END DEF
.
# Load test.bb is a test and demo program
It is still a long way to go

Post Reply