Skip to content

Instantly share code, notes, and snippets.

@paf31
Created March 29, 2014 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paf31/9862704 to your computer and use it in GitHub Desktop.
Save paf31/9862704 to your computer and use it in GitHub Desktop.
Fibonnaci sequence in PureScript
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 {};
})();
};
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