From 6c90abaf3da1e58b0031432f948e05f59f3a2603 Mon Sep 17 00:00:00 2001 From: evancz Date: Sat, 28 Jul 2012 20:31:57 +0200 Subject: [PATCH] Add comparison functions and some (int <-> float) functions. --- core-js/Prelude.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core-js/Prelude.js b/core-js/Prelude.js index c89c903..2809d8c 100644 --- a/core-js/Prelude.js +++ b/core-js/Prelude.js @@ -31,10 +31,22 @@ var Prelude = function() { fst : function(p) { return p[1]; }, snd : function(p) { return p[2]; }, rem : function(x) { return function(y) { return x % y; }; }, - div : function(x) { return function(y) { return x / y; }; }, + div : function(x) { return function(y) { return ~~(x / y); }; }, + compare : function(x) { return function (y) { + x = (typeof x === "object") ? toText(x) : x; + y = (typeof y === "object") ? toText(y) : y; + return [ x === y ? 'EQ' : (x < y ? 'LT' : 'GT') ]; + }; + }, + toFloat : function(x) { return x; }, + round : function(n) { return Math.round(n); }, + floor : function(n) { return Math.floor(n); }, + ceiling : function(n) { return Math.ceil(n); }, + truncate : function(n) { return ~~n; }, sqrt : Math.sqrt, abs : Math.abs, pi : Math.PI, + e : Math.E, sin : Math.sin, cos : Math.cos, tan : Math.tan,