source: imaps-frontend/node_modules/prelude-ls/lib/Num.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.4 KB
Line 
1// Generated by LiveScript 1.6.0
2var max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, pow, sin, tan, cos, asin, acos, atan, atan2, truncate, round, ceiling, floor, isItNaN, even, odd, gcd, lcm;
3max = curry$(function(x$, y$){
4 return x$ > y$ ? x$ : y$;
5});
6min = curry$(function(x$, y$){
7 return x$ < y$ ? x$ : y$;
8});
9negate = function(x){
10 return -x;
11};
12abs = Math.abs;
13signum = function(x){
14 if (x < 0) {
15 return -1;
16 } else if (x > 0) {
17 return 1;
18 } else {
19 return 0;
20 }
21};
22quot = curry$(function(x, y){
23 return ~~(x / y);
24});
25rem = curry$(function(x$, y$){
26 return x$ % y$;
27});
28div = curry$(function(x, y){
29 return Math.floor(x / y);
30});
31mod = curry$(function(x$, y$){
32 var ref$;
33 return ((x$) % (ref$ = y$) + ref$) % ref$;
34});
35recip = (function(it){
36 return 1 / it;
37});
38pi = Math.PI;
39tau = pi * 2;
40exp = Math.exp;
41sqrt = Math.sqrt;
42ln = Math.log;
43pow = curry$(function(x$, y$){
44 return Math.pow(x$, y$);
45});
46sin = Math.sin;
47tan = Math.tan;
48cos = Math.cos;
49asin = Math.asin;
50acos = Math.acos;
51atan = Math.atan;
52atan2 = curry$(function(x, y){
53 return Math.atan2(x, y);
54});
55truncate = function(x){
56 return ~~x;
57};
58round = Math.round;
59ceiling = Math.ceil;
60floor = Math.floor;
61isItNaN = function(x){
62 return x !== x;
63};
64even = function(x){
65 return x % 2 === 0;
66};
67odd = function(x){
68 return x % 2 !== 0;
69};
70gcd = curry$(function(x, y){
71 var z;
72 x = Math.abs(x);
73 y = Math.abs(y);
74 while (y !== 0) {
75 z = x % y;
76 x = y;
77 y = z;
78 }
79 return x;
80});
81lcm = curry$(function(x, y){
82 return Math.abs(Math.floor(x / gcd(x, y) * y));
83});
84module.exports = {
85 max: max,
86 min: min,
87 negate: negate,
88 abs: abs,
89 signum: signum,
90 quot: quot,
91 rem: rem,
92 div: div,
93 mod: mod,
94 recip: recip,
95 pi: pi,
96 tau: tau,
97 exp: exp,
98 sqrt: sqrt,
99 ln: ln,
100 pow: pow,
101 sin: sin,
102 tan: tan,
103 cos: cos,
104 acos: acos,
105 asin: asin,
106 atan: atan,
107 atan2: atan2,
108 truncate: truncate,
109 round: round,
110 ceiling: ceiling,
111 floor: floor,
112 isItNaN: isItNaN,
113 even: even,
114 odd: odd,
115 gcd: gcd,
116 lcm: lcm
117};
118function curry$(f, bound){
119 var context,
120 _curry = function(args) {
121 return f.length > 1 ? function(){
122 var params = args ? args.concat() : [];
123 context = bound ? context || this : this;
124 return params.push.apply(params, arguments) <
125 f.length && arguments.length ?
126 _curry.call(context, params) : f.apply(context, params);
127 } : f;
128 };
129 return _curry();
130}
Note: See TracBrowser for help on using the repository browser.