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 Main where | |
| import MontePi | |
| import System.IO | |
| main :: IO () | |
| main = do | |
| hSetBuffering stdout NoBuffering | |
| putStr "Please enter n = " | |
| n <- readLn :: IO Int |
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
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE DeriveGeneric #-} | |
| module Main where | |
| import Web.Scotty (get, post, delete, param, html, json, jsonData, scotty, ScottyM) | |
| import Data.Aeson (FromJSON, ToJSON) | |
| import Control.Monad.IO.Class (liftIO, MonadIO) | |
| import Control.Concurrent.STM (atomically, STM) | |
| import Control.Concurrent.STM.TChan |
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
| data BinTree a = Leaf | |
| | Node { nodeData :: a, left :: BinTree a, right :: BinTree a} | |
| deriving (Eq, Show) | |
| instance Functor BinTree where | |
| fmap f Leaf = Leaf | |
| fmap f (Node a l r) = Node (f a) (fmap f l) (fmap f r) | |
| toList :: BinTree a -> [a] |
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
| __git_ps1 () | |
| { | |
| local b="$(git symbolic-ref HEAD 2>/dev/null)"; | |
| if [ -n "$b" ]; then | |
| printf " (%s)" "${b##refs/heads/}"; | |
| fi | |
| } | |
| #PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]" | |
| PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;31m\]\$( __git_ps1 ) \[\033[01;34m\]\$\[\033[00m\] " |
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
| def propab(d: Int, n: Int, b: Int): Double = { | |
| Math.pow(b,d-1)/Math.pow(b,n) | |
| } | |
| def expected(n:Int, bf: Int): Double = { | |
| (1 to n).foldLeft(0.0)( (a:Double,b:Int) => a + (b*propab(b,n,bf)) ) | |
| } |
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
| //scalaVersion 2.9.2 | |
| //akkaVersion 2.0.1 | |
| import akka.actor._ | |
| import java.net.InetSocketAddress | |
| import akka.util.ByteString | |
| import java.net.Socket | |
| import akka.actor.IO.SocketHandle | |
| import akka.actor.IO._ | |
| import akka.routing.RoundRobinRouter |