LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

INCARY

Root / Submissions / [.]

MZ952Created:
A function that increments the elements of some array by some value. INCARY NumericArray[],StartingPosition,NumberOfElements,Value
DEF INCARY _A[],_P,_LN,V
 DIM P=MIN(MAX(_P,0),LEN(_A)-1)
 DIM LN=MIN(_LN,LEN(_A)-P)
 IF LN==0 THEN RETURN ENDIF
 DIM A[0]:COPY A,_A,P,LN
 ARYOP #AOPADD,A,A,V
 COPY _A,P,A
END
Doesn't work on strings.

DEF ADDARR ARR[],VA,ST,EL
 DIM A[LEN(ARR)]:FILL A,VA,ST,EL
 ARYOP #AOPADD,ARR,ARR,A
END

Replying to:chicken
DEF ADDARR ARR[],VA,ST,EL
 DIM A[LEN(ARR)]:FILL A,VA,ST,EL
 ARYOP #AOPADD,ARR,ARR,A
END
Haha I knew there was a better way :p Edit: I didn't know FILL accepted those parameters. That makes everything so much simpler. Still, though, you might have to do some bound checking on EL to prevent potential Out of range errors.