Last active
August 29, 2015 14:05
-
-
Save emiaj/4596fdd533edeb2a479d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var Prelude = require("Prelude"); | |
var Math = require("Math"); | |
var isEven = function (__copy__36) { | |
var _36 = __copy__36; | |
tco: while (true) { | |
if (_36 === 0) { | |
return false; | |
}; | |
if (_36 === 1) { | |
return false; | |
}; | |
if (_36 === 2) { | |
return true; | |
}; | |
if (_36 < 0) { | |
var __tco__36 = Math.abs(_36); | |
_36 = __tco__36; | |
continue tco; | |
}; | |
var __tco__36 = _36 - 2; | |
_36 = __tco__36; | |
continue tco; | |
}; | |
}; | |
module.exports = { | |
isEven: isEven | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Data.Experiments where | |
import Math | |
isEven :: Number -> Boolean | |
isEven 0 = true | |
isEven 1 = false | |
isEven n | n < 0 = isEven(Math.abs(n)) | |
isEven n = isEven(n-2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment