Deconstructing the JavaScript creation myth

To be fair to Brendan Eich, he probably could not have foreseen callback hell in 1995.
def toyExampleAdd(a: Int, b: Int): Int = {
a + b // "return" is implied
}
for {
m <- -10 to 10
n <- -10 to 10
} yield toyExampleAdd(m, n)
Vector(-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, -15, -14, -13, -12, -11, -10, -9, -8, -7, -...: scala.collection.immutable.IndexedSeq
def toyExampleAdd(a: Int, b: Int): Int = 
{
a +
b // "return" is implied
}
function toyExampleAdd(a, b) {
return a + b;
}
for (m = -10; m < 11; m++) {
for (n = -10; n < 11; n++) {
console.log(toyExampleAdd(m, n))
}
}
function toyExampleMultiply(a, b) {
return
a * b;
}
toyExampleMultiply(7, 2)
function fizzBuzz(n) {
switch (n % 15) {
case 0: return "FizzBuzz"
case 3:
case 6:
case 9:
case 12: return "Fizz"
case 5:
case 10: return "Buzz"
default: return n
}
}
fizzBuzz(93)fizzBuzz("93")fizzBuzz("G-20.in")
def fizzBuzz(n: Int): Any = (n % 3, n % 5) match {
case (0, 0) => "FizzBuzz"
case (0, _) => "Fizz"
case (_, 0) => "Buzz"
case _ => n
}
(-10 to 10).map(fizzBuzz(_))

is a composer and photographer from Detroit, Michigan. He has been working on a Java program to display certain mathematical diagrams.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store