The functions:
Code: Select all
; Returns a simple numeric array of length n with values initialized to 0
Zeros(n){
Local
VarSetCapacity(bli,n,48)
Return StrSplit(StrGet(&bli,n,"CP0"))
}
; Returns a simple numeric array of length n with values initialized to 1
Ones(n){
Local
VarSetCapacity(bli,n,49)
Return StrSplit(StrGet(&bli,n,"CP0"))
}
; Returns a simple numeric array of keys from 0 to n with values initialized to 0
Zeros0(n){
Local
VarSetCapacity(bli,n,48), Ali:=StrSplit(StrGet(&bli,n,"CP0")), Ali[0]:=0
Return Ali
}
; Returns a simple numeric array of keys from 0 to n with values initialized to 1
Ones0(n){
Local
VarSetCapacity(bli,n,49), Ali:=StrSplit(StrGet(&bli,n,"CP0")), Ali[0]:=1
Return Ali
}
Code: Select all
MsgBox, , Zeros(), % st_printArr(Zeros(10))
MsgBox, , Ones(), % st_printArr(Ones(10))
MsgBox, , Zeros0(), % st_printArr(Zeros0(10))
MsgBox, , Ones0(), % st_printArr(Ones0(10))
ExitApp
; Returns a simple numeric array of length n with values initialized to 0
Zeros(n){
Local
VarSetCapacity(bli,n,48)
Return StrSplit(StrGet(&bli,n,"CP0"))
}
; Returns a simple numeric array of length n with values initialized to 1
Ones(n){
Local
VarSetCapacity(bli,n,49)
Return StrSplit(StrGet(&bli,n,"CP0"))
}
; Returns a simple numeric array of keys from 0 to n with values initialized to 0
Zeros0(n){
Local
VarSetCapacity(bli,n,48), Ali:=StrSplit(StrGet(&bli,n,"CP0")), Ali[0]:=0
Return Ali
}
; Returns a simple numeric array of keys from 0 to n with values initialized to 1
Ones0(n){
Local
VarSetCapacity(bli,n,49), Ali:=StrSplit(StrGet(&bli,n,"CP0")), Ali[0]:=1
Return Ali
}
st_printArr(array, depth=5, indentLevel=""){
list:=""
for k,v in Array
{
list.= indentLevel "[" k "]"
if (IsObject(v) && depth>1)
list.="`r`n" st_printArr(v, depth-1, indentLevel . " ")
Else
list.=" => " v
list.="`r`n"
}
return rtrim(list)
}