Skip to content

Commit

Permalink
+ Implemented pow()
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Iversen committed Jan 15, 2012
1 parent cd55711 commit 589843a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pyjaco/stdlib/10-builtin.js
Expand Up @@ -338,7 +338,21 @@ __builtins__.PY$ord = function(ord) {
};


__builtins__.PY$pow = $PY.c_nif;
__builtins__.PY$pow = function(x, y, z) {
if (z !== undefined) {
throw __builtins__.PY$NotImplemented("Pyjaco does not support the 3-operand version of pow()");
} else if (x.PY$__pow__ !== undefined) {
if (y.obj < 0) {
return __builtins__.PY$float(x).PY$__pow__(y);
} else {
return x.PY$__pow__(y);
}
} else {
throw __builtins__.PY$TypeError("unsupported operand type(s) for ** or pow(): '" +
x.PY$__class__.PY$__name__ + "' and '" +
y.PY$__class__.PY$__name__ + "'");
}
};

if (typeof console !== 'undefined' && console.log !== undefined) {
if (console.log.apply !== undefined) {
Expand Down

0 comments on commit 589843a

Please sign in to comment.