? 🅱️ode 🅱️ritique (Page 3) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

🅱️ode 🅱️ritique

1 2 3
  • #41 ✎ 998 snail_ QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Helper Received for being very helpful around SmileBASIC Source Achievements Amazing Contributor Someone thinks I'm an awesome person who has done so much for the community! Achievements This doesnt return a string which could cause an error. Allow me to improve that for you. DEF RND$() RETURN FORMAT$("%D",RNDF()) END Posted
  • #42 ✎ 1000 Yttria Head Admin 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$ END Posted Edited by Yttria
  • #43 ✎ 1755 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself VAR 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 Posted
  • #44 ✎ 376 Chemicalex Drawing I like to draw! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength osu! Is Awesome! I love osu! Express Yourself Does it have to be Smile🅱️asic code? Posted
  • #45 ✎ 331 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength nah just get a random string like this: DEF RNDS() RETURN INPUT END or Lua: local a = "" function rndString(_len) for i = 1, math.random(_len) do a..string.char(math.random(255)) end return a end Posted Edited by spaceturtles
  • #46 ✎ 1755 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself
    nah just get a random string like this: DEF RNDS() RETURN INPUT END
    That doesn't even work
    Posted
  • #47 ✎ 331 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength
    nah just get a random string like this: DEF RNDS() RETURN INPUT END
    That doesn't even work
    the idea does?
    Posted
  • #48 ✎ 1755 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself
    this is 🅱️ode 🅱️ritique, not 🅱️idea 🅱️ritique
    Posted
  • #49 ✎ 331 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength
    this is 🅱️ode 🅱️ritique, not 🅱️idea 🅱️ritique
    English with emotes isn't a programming language
    Posted
  • #50 ✎ 1755 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Can someone please help improve my sorting function? It's too slow... DEF SORT_ARRAY (ARRAY[] ) DIM NEW [0] FOR J = 0 TO LEN(ARRAY) -1 FOR I=0 TO LEN(ARRAY) - 1 IF ARRAY[I] == MIN(ARRAY) THEN PUSH NEW, ARRAY[I] ARRAY[ I] = MAX( ARRAY ) BREAK ENDIF NEXT NEXT RETURN NEW END Posted Edited by 12Me21
  • #51 ✎ 1000 Yttria Head Admin '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 Posted
  • #52 ✎ 473 auceps '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 END Posted
  • #53 ✎ 287 ProKuku QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Night Person I like the quiet night and sleep late. Express Yourself Pokemon Is Awesome! I love Pokemon! Express Yourself Hi! I forgot math exists and only know how to use functions. Is there a simpler way to see if a numerical value is negative, other than using the complicated <0 and the too-convenient SGN( )function? Posted Edited by ProKuku
  • #54 ✎ 1755 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself IF value+(""*@_||!.) <3 THEN ... IF value>>value THEN ... Posted Edited by 12Me21
  • #55 ✎ 998 snail_ QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Helper Received for being very helpful around SmileBASIC Source Achievements Amazing Contributor Someone thinks I'm an awesome person who has done so much for the community! Achievements this should work: ON value*value AND VAL("&H8"+"0"*7) GOTO @POS,@NEG Posted Edited by snail_
  • #56 ✎ 1755 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself I need help writing an array rotate function [1,2,3,4,5] rotate left twice -> [3,4,5,1,2] Posted
  • #57 ✎ 331 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength DEF 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 END I can't remember what some of the basic array operation functions do like SHIFT Posted Edited by spaceturtles
1 2 3