Skip to content

Instantly share code, notes, and snippets.

#! /bin/bash
for i in {1..20}
do
for j in {1..20}
do
echo $((i+j)) $i $j
done
done | sort -n | while read sum i j
do
@Gozala
Gozala / example.js
Created January 29, 2012 03:46
Workaround for lack of "tail call optimization" in JS
// Lack of tail call optimization in JS
var sum = function(x, y) {
return y > 0 ? sum(x + 1, y - 1) :
y < 0 ? sum(x - 1, y + 1) :
x
}
sum(20, 100000) // => RangeError: Maximum call stack size exceeded
// Using workaround