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 RPNWriter where | |
| -- 逆ポーランド記法で書かれた式を計算する関数 solveRPN (p.214) に、 | |
| -- Writerモナドを使って計算経過ログをとる機能を追加してみよう。 | |
| import Control.Monad.Writer | |
| import Control.Applicative ((<$>)) | |
| import Data.Char (isDigit) | |
| solveRPNwithLog :: String -> Writer String Double | |
| solveRPNwithLog s = do |
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 PoleEither where | |
| import Control.Monad.Error () | |
| import Data.List (intersperse) | |
| type Birds = Int | |
| type Pole = (Birds, Birds) | |
| landLeft :: Birds -> Pole -> Either String Pole | |
| landLeft n (left, right) = |
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
| import qualified Data.Text.IO as TIO (hGetLine) | |
| import Data.Text (Text) | |
| import qualified Data.Text as T | |
| import System.IO | |
| import Control.Applicative ((<$>), (<*>), pure) | |
| hGetLines :: Handle -> IO [Text] | |
| hGetLines h = do | |
| eof <- hIsEOF h | |
| if eof |
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 Kuku where | |
| import qualified Data.Text as T | |
| import Data.Text (Text) | |
| import qualified Data.Text.IO as TIO | |
| -- general function | |
| showText :: (Show a) => a -> Text | |
| showText = T.pack . show |
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
| import Control.Monad | |
| import System.IO | |
| main :: IO () | |
| main = do | |
| putStr "あなたの名前は? " | |
| hFlush stdout | |
| eof <- isEOF | |
| if eof | |
| then |
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
| class Profile | |
| DEFAULT = "default" | |
| def self.generate_source name=DEFAULT | |
| %Q" | |
| #{self}.new #{name.dump} do|p| | |
| # Required Properties | |
| # DO NOT LEAVE THEM EMPTY! | |
| p.src = '' | |
| p.dest = '' |
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
| #!/usr/bin/ruby | |
| # -*- coding: utf-8 -*- | |
| $VERBOSE = true | |
| def new_section | |
| puts '-' * 80 | |
| end | |
| # Can a class variable be accessed from the class methods? | |
| class Hoge | |
| @@a = "in #{self}" |
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
| "Settings | |
| let g:vimplayer_mplayer_extra_options = [] | |
| let s:vimplayer_pipe_mplayer = {} | |
| function! vimplayer#play(...) abort | |
| let vimplayer_filenames = a:000 | |
| if !empty(s:vimplayer_pipe_mplayer) "mplayer already playing something | |
| call s:vimplayer_pipe_mplayer.stdin.write("quit\n") |
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
| #!/bin/bash | |
| #Execute command twice. | |
| #Sample to show that | |
| # It's more useful to use +eval+ and +source+ | |
| # if you want to decide which command to execute in your script | |
| shopt -s expand_aliases # don't work even if expand_aliases is enabled. | |
| # $@ #don't work well: don't expand the alias |
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
| alias tweet='cat ~/your-token.yaml | tw-post.rb' |