by skulk · 3y ago · 0 comments
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.
λ> 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));https://youtube.com/watch?v=F3feRCr6S64
(recommend watching it by doing the four "tests" before going to the reveal)
: 4 5 ;
2 2 + .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).