Created
March 29, 2014 20:49
-
-
Save paf31/9862704 to your computer and use it in GitHub Desktop.
Fibonnaci sequence in PureScript
This file contains 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
var main = function __do() { | |
var _4 = 1; | |
var _3 = 1; | |
return (function () { | |
while (_ps.Prelude.pure(_ps.Prelude.applicativeFromMonad(_ps.Control_Monad_Eff.monadEff({})))(true)()) { | |
(function __do() { | |
var _2 = _4; | |
var _1 = _3; | |
_3 = _2 + _1; | |
_4 = _1; | |
return _ps.Debug_Trace.print(_ps.Prelude.showNumber({}))(_1)(); | |
})(); | |
}; | |
return {}; | |
})(); | |
}; |
This file contains 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 Main where | |
import Control.Monad.Eff | |
import Control.Monad.ST | |
main = runST (do | |
n1 <- newSTRef 1 | |
n2 <- newSTRef 1 | |
whileE (pure true) $ do | |
n1' <- readSTRef n1 | |
n2' <- readSTRef n2 | |
writeSTRef n2 $ n1' + n2' | |
writeSTRef n1 n2' | |
Debug.Trace.print n2') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment