Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Num.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // Generated by LiveScript 1.4.0
  2. var 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;
  3. max = curry$(function(x$, y$){
  4. return x$ > y$ ? x$ : y$;
  5. });
  6. min = curry$(function(x$, y$){
  7. return x$ < y$ ? x$ : y$;
  8. });
  9. negate = function(x){
  10. return -x;
  11. };
  12. abs = Math.abs;
  13. signum = function(x){
  14. if (x < 0) {
  15. return -1;
  16. } else if (x > 0) {
  17. return 1;
  18. } else {
  19. return 0;
  20. }
  21. };
  22. quot = curry$(function(x, y){
  23. return ~~(x / y);
  24. });
  25. rem = curry$(function(x$, y$){
  26. return x$ % y$;
  27. });
  28. div = curry$(function(x, y){
  29. return Math.floor(x / y);
  30. });
  31. mod = curry$(function(x$, y$){
  32. var ref$;
  33. return (((x$) % (ref$ = y$) + ref$) % ref$);
  34. });
  35. recip = (function(it){
  36. return 1 / it;
  37. });
  38. pi = Math.PI;
  39. tau = pi * 2;
  40. exp = Math.exp;
  41. sqrt = Math.sqrt;
  42. ln = Math.log;
  43. pow = curry$(function(x$, y$){
  44. return Math.pow(x$, y$);
  45. });
  46. sin = Math.sin;
  47. tan = Math.tan;
  48. cos = Math.cos;
  49. asin = Math.asin;
  50. acos = Math.acos;
  51. atan = Math.atan;
  52. atan2 = curry$(function(x, y){
  53. return Math.atan2(x, y);
  54. });
  55. truncate = function(x){
  56. return ~~x;
  57. };
  58. round = Math.round;
  59. ceiling = Math.ceil;
  60. floor = Math.floor;
  61. isItNaN = function(x){
  62. return x !== x;
  63. };
  64. even = function(x){
  65. return x % 2 === 0;
  66. };
  67. odd = function(x){
  68. return x % 2 !== 0;
  69. };
  70. gcd = 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. });
  81. lcm = curry$(function(x, y){
  82. return Math.abs(Math.floor(x / gcd(x, y) * y));
  83. });
  84. module.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. };
  118. function 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. }