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 PackageImports #-} | |
import Control.Monad | |
import Control.Applicative ((<$>),(<*>)) | |
import "mtl" Control.Monad.RWS | |
import qualified System.Random as R | |
main = do |
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 PackageImports #-} | |
import Control.Monad | |
import Control.Applicative ((<$>),(<*>)) | |
import Control.Monad.ST | |
import Data.STRef | |
import "mtl" Control.Monad.State | |
main = do | |
print $ twdst 10 | |
print $ tdwst 10 |
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
-- n個の引数を持つ関数が、「1個の引数を持つ、n-1個の引数を持つ関数を返す関数」でもあること | |
-- haskell ではデフォルトで関数は「関数を返す関数」になっている | |
-- non curried function ( ordinary in another languages ) | |
foo:: (Int, Int, Int, Int) -> Int | |
foo (a, j, q, k ) = a + j + q + k | |
-- curried function ( ordinary in haskell ) | |
bar :: Int -> Int -> Int -> Int -> Int | |
bar a j q k = a + j + q + k |
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.Functor( (<$>) ) | |
import Control.Applicative( Applicative, (<*>) ) | |
import Prelude hiding( Left, Right ) | |
-- | |
-- 計算の合成(未評価の計算を使った計算) | |
-- | |
-- | |
-- Functor 単項演算子の適応(map) |
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 Prelude hiding( Left, Right ) | |
data Heading = North | East | West | South deriving( Show, Read ) | |
type Status = ( (Int, Int), Heading ) | |
data Direction = Forward | Backward | Left | Right deriving( Read ) | |
progress:: Direction -> Status -> Status | |
progress Forward ((x, y), North) = (( x, y+1 ), North) | |
progress Backward ((x, y), North) = (( x, y-1 ), South) | |
progress Left ((x, y), North) = (( x-1, y ), West ) |
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 ScopedTypeVariables #-} | |
module StopWatch where | |
import System.IO | |
import Control.Monad (when) | |
import Control.Concurrent.Timer | |
import Control.Concurrent.Suspend | |
import Data.Time.Clock | |
import Reactive.Banana |
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 StopWatch where | |
import System.IO | |
import Control.Monad (when) | |
import Control.Concurrent.Timer | |
import Control.Concurrent.Suspend | |
import Data.Time.Clock | |
import Data.IORef |
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
#!/bin/sh | |
# ./create_vm.sh vm1 Debian_64 1024 20000 3393 Downloads/debian-7.1.0-amd64-netinst.iso | |
# VBoxManage startvm vm1 -type headless | |
# VBoxManage unregistervm vm1 --delete | |
VM_NAME=$1 | |
OS_TYPE=$2 | |
MEMORY_SIZE=$3 |
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 System.Random.Mersenne( getStdGen, randoms ) | |
import Time | |
data Point = Point { x::Double, y::Double } deriving( Show ) | |
total = 10000000 | |
main = do | |
testStart <- getClockTime | |
gen <- getStdGen |
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
// file: identon2.cpp | |
// | |
// gcc -xc++ -lstdc++ identon2.cpp | |
// CL /TP /EHsc identon2.cpp | |
#include <limits.h> | |
#include <sstream> | |
#include <iostream> |