🅱️ode 🅱️ritique
The last answer returned a string which might have numbers in it, which might cause erroneous behavior if the caller does not expect numbers in a string. Allow me to improve that for you.
Edit: I messed up!
DEF RNDWOD$()
VAR S$ = FORMAT$("%F",RNDF())
VAR I = 0, C$
WHILE I < LEN(S$)
C$ = S$[I]
'remove char if it is a digit
IF C$>="0"&&C$<="9" THEN S$[I]="" ELSE INC I,1
WEND
RETURN S$
ENDVAR PI$=STR$(PI()) VAR I 'Returns the next digit of pi when called DEF RND$() INC I I=I%LENGTH(PI$) 'make sure the index doesn't exceed the length of PI$ RETURN PI$[I] END 'get the length of a string DEF LENGTH S$ VAR I WHILE MID$(S$,I,1)!="" 'MID$ returns an empty string when out of range INC I WEND RETURN I END
Does it have to be Smile🅱️asic code?
nah just get a random string like this:
DEF RNDS() RETURN INPUT ENDor Lua: local a = "" function rndString(_len) for i = 1, math.random(_len) do a..string.char(math.random(255)) end return a end
the idea does?nah just get a random string like this:That doesn't even workDEF RNDS() RETURN INPUT END
English with emotes isn't a programming languagethis is 🅱️ode 🅱️ritique, not 🅱️idea 🅱️ritique
'sort an array, javascript style, with some lewd easter eggs
DEF jsSort(A[])
DIM N$[0], E$
WHILE LEN(A)
'valentine's day edition <3
IF (A[0]||0)<3 THEN
PUSH N$,STR$(POP(A))
ELSE
PUSH N$,POP(A)
ENDIF
'valentine's day edition OWO
FOR I = LEN(N) -1 TO 1 STEP -1
IF N$[I] <= N$[I-1] THEN
SWAP N$[I], N$[I-1]
ELSE
BREAK
ENDIF
NEXT
WEND
RETURN N$
END'please dont use 0.00199
DEF NORT(INP[])
DIM RET[LEN(INP)],RES,W,V
FILL RET,0.00199
FOR I=0 TO LEN(INP)-1
RES=0
W=INP[I]
FOR _I=0 TO LEN(INP)-1
V=INP[_I]
INC RES,ABS(0.5+ABS(W-V)/(2*(W-V))*(W-V)/(W-V))
NEXT
IF RET[RES]==INP[I] THEN
REPEAT
INC RES
UNTIL RET[RES] != INP[I]
ENDIF
RET[RES]=INP[I]
NEXT
RETURN RET
ENDDEF ROTATE ARR[], N%, LEFT% IF LEFT% THEN FOR I=0 TO N%-1 TMP=UNSHIFT(ARR) PUSH ARR, TMP NEXT ELSE FOR I=0 TO N%-1 TMP=POP(ARR) SHIFT ARR, TMP NEXT ENDIF RETURN ARR ENDI can't remember what some of the basic array operation functions do like SHIFT
Is there a better function for inserting an array into an array?
DEF ARYINS A[],_P,IN[] IF !LEN(IN) THEN RETURN ENDIF DIM P=MIN(MAX(_P,0),LEN(A)-1) DIM A0[0]:COPY A0,A,0,P COPY A0,LEN(A0),IN DIM A1[0]:COPY A1,A,P,LEN(A)-P COPY A0,LEN(A0),A1:COPY A,A0 ENDEdit: oh wait this thread is a meme. Where do I find the actual thread for critiquing functions lol Edit 2: can't find one, so I'm just going to pretend this is the thread I'm looking for. Edit 3: I've been 🅱️unked. This may not be the thread I'm looking for...