J vs Javascript vs PicoLisp short comparison on [2014-01-15 Wed 13:21]

+/\(1 _1 0){~'{}' i. '@{ foo; if (abc) { if (q) { m; } } }'

0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 2 2 1 1 0

var runsum=0;'@{ foo; if (abc) { if (q) { m; } } }'.split('').map(function(x) { var opp={'{':1,'}':-1}; return opp[x]||0;  }).map(function(x) { runsum = x+runsum; return runsum; })

0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 2, 1, 1, 0

(reverse (mapcon '((X) (list (apply + X))) (reverse (mapcar '((X) (cond ((= X "{") 1) ((= X "}") -1) (T 0))) (chop "@{ foo; if (abc) { if (q) { m; } } }")) ) ))

(0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 2 2 1 1 0)




Prev: J for spreadsheet calculations  Next: J rank in a nutshell