更新: | 2014-04-10 |
---|---|
バージョン: | 0.2.1 |
作者: | @voluntas |
URL: | http://voluntas.github.io/ |
reltool 周りについて勉強がてらまとめてみました
更新: | 2014-04-10 |
---|---|
バージョン: | 0.2.1 |
作者: | @voluntas |
URL: | http://voluntas.github.io/ |
reltool 周りについて勉強がてらまとめてみました
-- http://koko-u.github.com/haskell_book_reading/#25 | |
import Data.Char (toUpper, intToDigit, isSpace) | |
import Data.List (isInfixOf, nub) | |
import Numeric (showIntAtBase) | |
upperCase :: String -> String | |
upperCase = map toUpper | |
removeSpaces :: String -> String |
module Main where | |
import Control.Monad | |
import Control.Monad.Free | |
import Prelude hiding (putChar, getChar) | |
import qualified System.IO as IO | |
import Test.QuickCheck | |
---------------------------------------------------------------- | |
-- Our DSL |
-- ex1 | |
-- my null | |
null' xs = xs == [] | |
-- my sum | |
sum' xs = if null' xs then 0 else head xs + sum' (tail xs) | |
-- my product | |
product' xs = if null' xs then 1 else head xs * product' (tail xs) |
{-# LANGUAGE FlexibleInstances, OverlappingInstances #-} | |
module Main where | |
import Data.Monoid | |
import Control.Monad | |
instance Monad m => Monoid (a -> m a) where | |
mempty = return | |
mappend = (>=>) | |
main :: IO () |
{--- 余再帰とその利用例 ---} | |
{- 末尾再帰と再帰と余再帰 | |
- | |
- 参考: http://d.hatena.ne.jp/kazu-yamamoto/20091122/1258899591 | |
- | |
- 末尾再帰 : 引数に結果を蓄積し、自身へgotoして処理の流れが戻ってこないようにする。正格なデータを処理する時に用いるとスタックやヒープの節約になる。 | |
- foldl f a [] = a | |
- foldl f a (x:xs) = foldl f (f a x) xs | |
- |
# http://aws.amazon.com/amazon-linux-ami/ | |
# http://aws.amazon.com/amazon-linux-ami/faqs/ | |
# Boot up a machine with at least 1.5 to 2 GB Ram | |
# login | |
chmod 600 key.pem | |
ssh -i key.pem [email protected] | |
# update |