4 ms·
Minor note: > A = { n^2 : n = 1, 2, …, 100 } > In Python, or interpreting the expression literally, the value of n would be a tuple, producing a type error. (
by nothrabannosir 9y ago
Minor note:
> A = { n^2 : n = 1, 2, …, 100 }
> In Python, or interpreting the expression literally, the value of n would be a tuple, producing a type error. (In Javascript, it produces 2.[link] How could it be Javascript if it didn’t?)
That linked JS code uses ^, which is xor, not pow. Math.pow([], 2) = NaN. Or maybe that was the joke and it flew completely over my head.
- lotharbot 9y agoI suspect that's the joke. Making fun of how Javascript parses or evaluates expressions is a favorite passtime in programmer circles. See, for example, https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat