Skip to content

Instantly share code, notes, and snippets.

View taisyo7333's full-sized avatar

Daisuke Inoue taisyo7333

View GitHub Profile
@taisyo7333
taisyo7333 / make.cmd
Last active August 29, 2015 14:24
Haskell : todo
ghc --make todo.hs
@taisyo7333
taisyo7333 / Random2Times.hs
Last active August 29, 2015 14:24
Haskell : random
import System.Random
-- getStdGen , newStdGen
-- If you use getStdGen 2 times , you can get the same result.
-- In this case , you can use newStdGen instead of getStdGen after the first time you use getStdGen.
main = do
gen <- getStdGen
putStrLn $ take 20 (randomRs ('a','z') gen )
gen' <- newStdGen
putStrLn $ take 20 (randomRs ('a','z') gen' )
@taisyo7333
taisyo7333 / make_directory.ps1
Last active August 29, 2015 14:25
Powershell :カレントディレクトリをディレクトリ"ディレクトリ名"を作成する
New-Item -ItemType Directory -Name ディレクトリ名
@taisyo7333
taisyo7333 / arg.hs
Created July 15, 2015 15:03
Haskell : Arguments and program name are ... .
import System.Environment
import Data.List
{-
>.\arg.exe abc xyz "123 456"
The arguments are:
abc
xyz
123 456
The program name is:
arg.exe
@taisyo7333
taisyo7333 / copy.hs
Created July 17, 2015 13:50
Haskell ByteString Samle
import System.Environment
import System.Directory -- openTempFile , removeFile
import System.IO
import Control.Exception -- bracketOnError
import qualified Data.ByteString.Lazy as B
{-
This code is referenced from "Learn You a Haskell for Great Good!!"
-}
main = do
@taisyo7333
taisyo7333 / rpn.hs
Last active August 29, 2015 14:25
Haskell : Reverse Polish Notation
{-
Reverse Polish Notation
>example
rpn "10 4 3 + 2 * - "
-4.0
rpn "30 4 +"
34.0
rpn "4 3 + 10 *"
@taisyo7333
taisyo7333 / output_sample.txt
Last active August 29, 2015 14:25
Haskell : RoutePath Sample
>runhaskell RoutePath.hs < paths.txt
The best path to take is : BCACBBC
Time taken: 75
@taisyo7333
taisyo7333 / Translate.hs
Last active August 29, 2015 14:25
translate InFix notation into PostFix notation.
module Translate
( toPostFix
, translate
) where
import Data.Char
import qualified Data.Map as Map
-- ("operator",priority)
operators = Map.fromList [ ("+",1)
@taisyo7333
taisyo7333 / parse_calculator.cpp
Created July 31, 2015 15:12
C++ 四則演算を再帰下降構文解析する
#include<string>
#include<iostream>
// arg1 : 評価する式
// arg2 : 式の参照位置
// return : std::pair<構文解析結果,次の参照位置>
using RESULT = std::pair < int, size_t > ;
RESULT expr(const std::string&, size_t);
RESULT term(const std::string&, size_t);
RESULT factor(const std::string&, size_t);
@taisyo7333
taisyo7333 / .gitconfig
Created August 20, 2015 04:25
My .gitconfig
[merge]
tool = WinMerge
[mergetool "WinMerge"]
cmd = \"C:/Program Files/WinMerge/WinMergeU.exe\" //e //u //wl //wr \"$LOCAL\" \"$BASE\" \"$REMOTE\" //o \"$MERGED\"
trustExitCode = true
[mergetool "kdiff3"]
path = C:/Program Files/KDiff3/kdiff3.exe
[diff]
guitool = winmerge
[difftool "kdiff3"]