4 ms·
Related: one of my favorite StackExchange questions: "Write a program that makes 2+2=5" https://codegolf.stackexchange.com/questions/28786/write-a-program-that
by skulk 3y ago
Related: one of my favorite StackExchange questions: "Write a program that makes 2+2=5"
https://codegolf.stackexchange.com/questions/28786/write-a-program-that-makes-2-2-5 https://codegolf.stackexchange.com/questions/28786/write-a-p...
Really shows you the skeletons hiding in some languages. My favorite is Haskell, which will happily do what you tell it to.
- deleted 3y ago[deleted]
- fbdab103 3y agoI legit burst out laughing at the C solution (https://codegolf.stackexchange.com/a/28889 https://codegolf.stackexchange.com/a/28889). Definitely got me.
- codeflo 3y agoThe Haskell one is not that spectacular if you understand that operators are just functions in that language: λ> let 2+2=5 in 2+2 5 This simply defines a new local function that happens to be called "+". It's no different than something like this in JavaScript: let Math = { sqrt: (x) => 42 }; console.log(Math.sqrt(16));
- lloeki 3y agoThe Ruby versions are a bit underwhelming, this is not 2+2=5 but much more underhanded: https://youtube.com/watch?v=F3feRCr6S64 https://youtube.com/watch?v=F3feRCr6S64 (recommend watching it by doing the four "tests" before going to the reveal)
- jacketing 3y agoForth is probably cheating considering it has no restrictions when naming symbols. : 4 5 ; 2 2 + .
- jstanley 3y agoDid you try this? This won't work. What you did will make inputting a 4 yield a 5, but it won't change the behaviour of outputting a 4. (And it will only turn an input 4 into a 5 if your interpreter checks for words before checking for numbers which is not universally the case).
- pgeorgi 3y agoTry : + drop drop 5 ;
- m6g6a 3y agothis is how javascript works
- bityard 3y agoThis reminds me of an SO user that was eventually banned because he (or possibly she, we will never know) had a hobby of writing fairly detailed questions that looked totally innocent on the surface but got strange once you started digging into them. Those that suffered through would eventually realize the whole thing was masterfully crafted to waste your time. There was once an excellent collection of these but I can't find it now and wish for the life of me I could.