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
import Data.Vector.Unboxed as U | |
import System.Random.MWC | |
main :: IO () | |
main = withSystemRandom . asGenIO $ \gen -> do | |
x <- uniformVector gen 10000000 :: IO (U.Vector Double) | |
print (U.sum x) | |
-- jtobin@castor:~/sandbox$ time ./Rand +RTS -s | |
-- 4999721.338394913 |
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
{-# OPTIONS_GHC -Wall #-} | |
{-# OPTIONS_GHC -fno-warn-type-defaults #-} | |
{-# LANGUAGE BangPatterns #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE RecordWildCards #-} | |
import Control.Comonad | |
import Control.Comonad.Cofree |
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 foo = eth.accounts[0]; | |
personal.unlockAccount(foo, 'mypassword'); | |
miner.setEtherbase(foo); | |
var crowdSrc = "contract token { mapping (address => uint) public coinBalanceOf; event CoinTransfer(address sender, address receiver, uint amount); function token(uint supply) { if (supply == 0) supply = 10000; coinBalanceOf[msg.sender] = supply; } function sendCoin(address receiver, uint amount) returns(bool sufficient) { if (coinBalanceOf[msg.sender] < amount) return false; coinBalanceOf[msg.sender] -= amount; coinBalanceOf[receiver] += amount; CoinTransfer(msg.sender, receiver, amount); return true; } } contract Crowdsale { address public beneficiary; uint public fundingGoal; uint public amountRaised; uint public deadline; uint public price; token public tokenReward; Funder[] public funders; event FundTransfer(address backer, uint amount, bool isContribution); struct Funder { address addr; uint amount; } /* runs on init */ function Crowdsale( address _beneficiary , uint _fundingGoal , uint _duration , uint _pric |
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
vagrant@debian-jessie:~$ mkdir stackexchange-example-chain | |
vagrant@debian-jessie:~$ geth --genesis local_genesis.json --datadir stackexchange-example-chain --ne | |
tworkid 9991 --nodiscover --maxpeers 0 account new | |
Your new account is locked with a password. Please give a password. Do not forget this password. | |
Passphrase: | |
Repeat passphrase: | |
Address: {699ec6d49641e59f65ba4bf72c52628059301e64} | |
vagrant@debian-jessie:~$ geth --genesis local_genesis.json --datadir stackexchange-example-chain --networkid 9991 --nodiscover --maxpeers 0 console | |
I0215 10:08:11.260323 ethdb/database.go:71] Alloted 16MB cache to stackexchange-example-chain/chaindata | |
I0215 10:08:11.288895 ethdb/database.go:71] Alloted 16MB cache to stackexchange-example-chain/dapp |
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
{ | |
"nonce": "0xcafebabecafebabe", | |
"timestamp": "0x0", | |
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", | |
"extraData": "0x0", | |
"gasLimit": "0xfffffff", | |
"difficulty": "0x400", | |
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", | |
"coinbase": "0x3333333333333333333333333333333333333333", | |
"alloc": { |
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
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE TypeFamilies #-} | |
import Data.Functor.Foldable hiding (Foldable, Unfoldable) | |
import qualified Data.Functor.Foldable as RS (Foldable, Unfoldable) | |
data Expr = | |
Num Int | |
| Sum Expr Expr |
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
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE TypeFamilies #-} | |
import Data.Functor.Foldable | |
data ListF a r = | |
ConsF a r | |
| NilF | |
deriving (Show, Functor) |
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
{-# LANGUAGE BangPatterns #-} | |
import Control.DeepSeq | |
import qualified Data.Vector.Unboxed as U | |
import System.Random.MWC | |
import Control.Monad | |
import Criterion.Main | |
import Criterion.Config | |
newtype AffineTransform = AffineTransform { |
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
{-# OPTIONS_GHC -Wall #-} | |
import Data.Function | |
import Data.List | |
main :: IO () | |
main = print $ minimumBy (compare `on` sumDiffs) portfolios | |
-- Data ------------------------------------------------------------------------ |
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
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
data Program f a = Program { | |
annotation :: a | |
, running :: f (Program f a) | |
} |