Skip to content

Instantly share code, notes, and snippets.

{-# OPTIONS -Wall -Werror #-}
{-
https://gist.github.com/fujiyan/483893d875ff7e350ef1
-}
data Warrior = Warrior { attack :: Int } deriving (Show)
data Monster = Monster { hitPoint :: Int, defence :: Int } deriving (Show)
data Attack = Normal | Critical | Gira | Begirama
damage :: Warrior -> Monster -> Attack -> Int
damage (Warrior a) (Monster _ d) Normal
import Data.Char
import System.Environment
myLength :: String -> Int
myLength [] = 0
myLength (x:xs) = if isAscii x then 1 else 2 + myLength xs
main = do
args <- getArgs
let shi = if null args then "死" else args !! 0
import Control.DeepSeq
import Data.Char(toUpper)
main = do
str <- readFile "inout.txt"
str `deepseq` writeFile "inout.txt" (map toUpper str)
{-
% runghc toUpper.hs
-}
#include <stdio.h>
int main()
{
if (int x = 0) {
printf("true: %d\n", x);
//printf("true: %d, ?: %d\n", x, y); // ‘y’ was not declared in this scope
} else if (int y = 0) {
printf("false: %d, true: %d\n", x, y);
} else {
printf("false: %d, false: %d\n", x, y);

第13章 モナドがいっぱい

13.1 アプリカティブファンクターを強化する

Functor → Applicative Functor → Monad

Functor

ghci> :t fmap

fpinscala読書会#3

Contents

  • 2 Getting started with functional programming in Scala
  • 2.5 Polymorphic functions: abstracting over types
  • 2.6 Following types to implementations
  • 3 Functional data structures
  • 3.1 Defining functional data structures
  • 3.2 Pattern matching

fpinscala読書会#8

Contents

  • 5.4 Infinite streams and corecursion

前回の補足

import しておけば、定義より手前で使う時に Stream.cons のように書かなくて済む。

package fpinscala.laziness
# based on the example in https://docs.python.org/2.7/library/multiprocessing.html
from multiprocessing import Process, Queue, Manager
def f(q):
q.put('X' * 1000000)
if __name__ == '__main__':
manager = Manager()
queue = manager.Queue()
p = Process(target=f, args=(queue,))
#!/bin/bash
BRANCH=$(git rev-parse --abbrev-ref HEAD)
REMOTE=$(git config --get branch.${BRANCH}.remote)
if [ -z ${REMOTE} ]; then
echo "no remote"
exit -1
fi
git fetch
if [ $? != 0 ]; then
@yoichi
yoichi / ddd_c1.md
Last active November 24, 2015 21:45

ドメイン駆動設計 (Domain-Driven Design) 読書会#1

まえがき

対象的な3つのプロジェクト

  • いずれも役立つソフトウェアを完成させた
  • 野心的な目標を達成し、継続的な要求を満たすべく進化しつづけたのは1つだけ
  1. ドメインモデルなし