Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add gcd operation? are the signatures the way we want? #1427

Open
wants to merge 1 commit into
base: horizon
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/arr/compiler/compile-structs.arr
Original file line number Diff line number Diff line change
Expand Up @@ -2721,6 +2721,7 @@ runtime-provides = provides("builtin://global",
"num-atan", t-number-unop,
"num-atan2", t-number-binop,
"num-modulo", t-number-binop,
"num-gcd", t-number-binop,
"num-remainder", t-number-binop,
"num-truncate", t-number-unop,
"num-sqrt", t-number-unop,
Expand Down
8 changes: 8 additions & 0 deletions src/js/base/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -4964,6 +4964,13 @@ function (Namespace, jsnums, codePoint, util, exnStackParser, loader, seedrandom
return thisRuntime.makeNumberBig(jsnums.remainder(n, m, NumberErrbacks));
}

var num_gcd = function(n, m) {
if (arguments.length !== 2) { var $a=new Array(arguments.length); for (var $i=0;$i<arguments.length;$i++) { $a[$i]=arguments[$i]; } throw thisRuntime.ffi.throwArityErrorC(["num-gcd"], 2, $a, false); }
thisRuntime.checkArgsInternal2("Numbers", "num-gcd",
n, thisRuntime.Number, m, thisRuntime.Number);
return thisRuntime.makeNumberBig(jsnums.gcd(n, [m], NumberErrbacks));
}

var num_truncate = function(n) {
if (arguments.length !== 1) { var $a=new Array(arguments.length); for (var $i=0;$i<arguments.length;$i++) { $a[$i]=arguments[$i]; } throw thisRuntime.ffi.throwArityErrorC(["num-truncate"], 1, $a, false); }
thisRuntime.checkArgsInternal1("Numbers", "num-truncate",
Expand Down Expand Up @@ -5597,6 +5604,7 @@ function (Namespace, jsnums, codePoint, util, exnStackParser, loader, seedrandom
'num-truncate': makeFunction(num_truncate, "num-truncate"),
'num-sqrt': makeFunction(num_sqrt, "num-sqrt"),
'num-sqr': makeFunction(num_sqr, "num-sqr"),
'num-gcd': makeFunction(num_gcd, "num-gcd"),
'num-ceiling': makeFunction(num_ceiling, "num-ceiling"),
'num-floor': makeFunction(num_floor, "num-floor"),
'num-round': makeFunction(num_round, "num-round"),
Expand Down
1 change: 1 addition & 0 deletions src/js/trove/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
"num-sin":{'bind': 'fun', 'flatness': 0, 'name': 'num-sin', 'typ': 'NumUnop'},
"num-tan":{'bind': 'fun', 'flatness': 0, 'name': 'num-tan', 'typ': 'NumUnop'},

"num-gcd":{'bind': 'fun', 'flatness': 0, 'name': 'num-gcd', 'typ': 'NumBinop'},
"num-modulo":{'bind': 'fun', 'flatness': 0, 'name': 'num-modulo', 'typ': 'NumBinop'},
"num-remainder":{'bind': 'fun', 'flatness': 0, 'name': 'num-remainder', 'typ': 'NumBinop'},

Expand Down