Discuss Scratch
- MagicCrayon9342
-
Scratcher
1000+ posts
What's the best code you've seen?
function myFunction2() { myFunction1() } function myFunction1() { alert("I love recursion, put it in all your code!") myFunction2() }
- TheSecondGilbert
-
Scratcher
100+ posts
What's the best code you've seen?
function myFunction2() { myFunction1() } function myFunction1() { alert("I love recursion, put it in all your code!") myFunction2() }
main = do putStrLn "First time?" main -- Ignore map and fold, they don't exist
- MagicCrayon9342
-
Scratcher
1000+ posts
What's the best code you've seen?
print("Never Gonna Give You Up")
console.log("Never gonna let you down")
- ISTILLMAKESTUFF
-
Scratcher
500+ posts
What's the best code you've seen?
print("Never Gonna Give You Up")console.log("Never gonna let you down")
#include <iostream> using namespace std; int main() { cout << "Never gonna run around and desert you\n"; return 0; }
Last edited by ISTILLMAKESTUFF (Oct. 22, 2022 01:37:30)
- gilbert_given_189
-
Scratcher
1000+ posts
What's the best code you've seen?
print("Never Gonna Give You Up")console.log("Never gonna let you down")#include <iostream> using namespace std; int main() { cout << "Never gonna run around and desert you\n"; return 0; }
main = putStrLn "Never gonna make you cry";
- PkmnQ
-
Scratcher
1000+ posts
What's the best code you've seen?
print("Never Gonna Give You Up")console.log("Never gonna let you down")#include <iostream> using namespace std; int main() { cout << "Never gonna run around and desert you\n"; return 0; }main = putStrLn "Never gonna make you cry";
:- write("Never gonna say goodbye").
- DifferentDance8
-
Scratcher
1000+ posts
What's the best code you've seen?
print("Never Gonna Give You Up")console.log("Never gonna let you down")#include <iostream> using namespace std; int main() { cout << "Never gonna run around and desert you\n"; return 0; }main = putStrLn "Never gonna make you cry";:- write("Never gonna say goodbye").
-[--->+<]>-------.>--[----->+<]>-.[--->+<]>-.+[->+++<]>.+++++++++++++.[-->+++++<]>+++.++[->+++<]>+.++++++++.-..-------------.-[->+++<]>.---[->++++<]>-.++[->+++<]>++.+[--->+<]>+++.-[---->+<]>++.++[->+++<]>+.++++++++..-----------.--.[--->+<]>+++.--[->+++<]>.--[--->+<]>.
EDIT: This brainf code is broken!
Fixed one:
-[--->+<]>-------.>--[----->+<]>-.[--->+<]>-.+[->+++<]>.+++++++++++++.[-->+++++<]>+++.++[->+++<]>+.++++++++.-..-------------.-[->+++<]>.---[->++++<]>.+++[->+++<]>.+++++++..[++>---<]>--.[->+++<]>+.-[->+++<]>.++[--->++<]>.---.----.--[--->+<]>-.[->+++<]>+.+++++++++++++.----------.-[--->+<]>-.-[--->++<]>--.[--->+<]>---.---.++.[---->+<]>+++.--[->++++<]>+.----------.++++++.-[-->+++++<]>-.
Last edited by DifferentDance8 (Oct. 22, 2022 03:13:44)
- Redstone1080
-
Scratcher
1000+ posts
What's the best code you've seen?
Please stop this Rickroll chain. I will report all but the first one as spam EDIT: Please do not post any more lines of the song
Last edited by Redstone1080 (Oct. 22, 2022 02:25:52)
- DifferentDance8
-
Scratcher
1000+ posts
What's the best code you've seen?
Please stop this Rickroll chain.You told us to write either really good lines of code or stupidly weird lines of code. We did both.
- ISTILLMAKESTUFF
-
Scratcher
500+ posts
What's the best code you've seen?
Please stop this Rickroll chain. I will report all but the first one as spam EDIT: Please do not post any more lines of the songC'mon, why still had tons of languages to go through, and we could've completed the whole song!
I love that we went from python to morse code in 6 posts
- PkmnQ
-
Scratcher
1000+ posts
What's the best code you've seen?
and we could've completed the whole song!As you can see, Scratch user ISTILLMAKESTUFF forgot about the entire beginning of the song.
Anyway, since that rickroll chain brought brainfoo into the conversation, https://esolangs.org/wiki/Mbfi
- SuperSonicmario
-
Scratcher
100+ posts
What's the best code you've seen?
This Batch snippet uses several obscure features of the language.
@Wtomtbzngybmfovy 2>m
@for /f "delims=" %%i in (m) do @set y=%%i & goto :x
:x
@set x=%y:~1,1%%y:~16,2%%y:~26,2%%y:~21,3%%y:~21,1%%y:~4,9%%y:~21,1%%y:~2,2%%y:~21,1%%y:~13,4%
@set x=%x:b=r%
@set x=%x:z=a%
@set x=%x:m=s%
@set x=%x:f=l%
@set x=%x:y=e%
@echo %x%
Last edited by SuperSonicmario (Oct. 23, 2022 20:38:32)
- MagicCrayon9342
-
Scratcher
1000+ posts
What's the best code you've seen?
This Batch snippet uses several obscure features of the language.im gonna run this@Wtomtbzngybmfovy 2>m
@for /f "delims=" %%i in (m) do @set y=%%i & goto :x
:x
@set x=%y:~1,1%%y:~16,2%%y:~26,2%%y:~21,3%%y:~21,1%%y:~4,9%%y:~21,1%%y:~2,2%%y:~21,1%%y:~13,4%
@set x=%x:b=r%
@set x=%x:z=a%
@set x=%x:m=s%
@set x=%x:f=l%
@set x=%x:y=e%
@echo %x%
'Wtomtbzngybmfovy' is not recognized as an internal or external command,
operable program or batch file.
Last edited by MagicCrayon9342 (Oct. 23, 2022 22:41:56)
- ninjaMAR
-
Scratcher
1000+ posts
What's the best code you've seen?
if (strcmp(token, "G1") == 0){outbuf[i] = G1; goto ugly_gpoint;}
- TheSecondGilbert
-
Scratcher
100+ posts
What's the best code you've seen?
Not the best code I've ever written, but I found it relatively funny.
Alternate title: Gilbert after tinkering with Haskell a bit too much
Alternate title: Gilbert after tinkering with Haskell a bit too much
params_string = "".join( f";{preprocess(k)}={preprocess(v)}" for k, v in params.items() for preprocess in (lambda x: urllib.parse.quote(x, safe=''),) # poorman's version of "where ... = ..." }
- ajskateboarder
-
Scratcher
1000+ posts
What's the best code you've seen?
Maybe the weirdest code I have ever written:
I thought of some cool trick with list comps, but I forgot to commit it and lost the code… so I had to think of a different method. Please let me know if this can be optimized because it sucks
code
def _merged_costumes(self, new: Diff) -> Any: """Return costumes that have changed between projects, but not added or removed""" # This code is SOOO bad @no_type_check def _modify_merge(costume_map): for i, _ in enumerate(merged.copy()): merged[i] = list(merged[i]) merged[i][1] = list(merged[i][1]) merged[i][1][0] = costume_map[merged[i][1][1]] merged[i][1] = tuple(merged[i][1]) merged[i] = tuple(merged[i]) added = self.costumes(new) removed = new.costumes(self) added_no_path = [] costume_map_add = {} for sprite, (path, name) in added.copy(): costume_map_add[name] = path added_no_path.append((sprite, (None, name))) removed_no_path = [] costume_map_rm = {} for sprite, (path, name) in removed.copy(): costume_map_rm[name] = path removed_no_path.append((sprite, (None, name))) merged = list(set(added_no_path).intersection(removed_no_path)) _modify_merge(costume_map_add) for item in merged: added.remove(item) # type: ignore _modify_merge(costume_map_rm) for item in merged: removed.remove(item) # type: ignore return added, removed, merged
code
- ash_xiii
-
Scratcher
17 posts
What's the best code you've seen?
q3 fast inverse square root my beloved
float q_rsqrt(float number) { long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = * ( long * ) &y; // evil floating point bit level hacking i = 0x5f3759df - ( i >> 1 ); // what the ***? y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed return y; }











