All pastes #413900 Raw Edit

perl's cmp op. in JS

public javascript v1 · immutable
#413900 ·published 2007-03-28 19:26 UTC
rendered paste body
<script># Albert's Great CMP replacement for freakin' JavaScriptfunction cmp(a,b) { return a == b ? 0 : (a > b ? 1 : -1); }# The Great Test Suite (tm)document.write("1, 1: " + cmp(1,1) + "<br/>\n");document.write("1, -1: " + cmp(1,-1) + "<br/>\n");document.write("-1, 1: " + cmp(-1,1) + "<br/>\n");</script>