Skip to content

Instantly share code, notes, and snippets.

View fumieval's full-sized avatar
🐦
Birb

Fumiaki Kinoshita fumieval

🐦
Birb
View GitHub Profile
data Gender = Male | Female deriving (Show, Eq)
data Race = Martian | Venusian deriving (Show, Eq)
answer (Venusian, Male) = id
answer (Martian, Female) = id
answer (Venusian, Female) = not
answer (Martian, Male) = not
race x = (x==).fst
gender x = (x==).snd
@fumieval
fumieval / gist:1178337
Created August 29, 2011 12:57
Haskellで顔文字
infixl 9 ^-^ -- 笑顔
infixl 9 >< --
infixl 9 <.><.> -- 眼
infixl 9 .^. --逆立ち
d >< b = (b, d)
o <.><.> m = m * o * m
p ^-^ q = show p ++ " ^-^ " ++ show q
r .^. h = ((-r) ^ h, (-h) ^ r)
@fumieval
fumieval / gist:1180852
Created August 30, 2011 13:16
同一の機構を持つスパムと思われるアカウント cf. http://togetter.com/li/181115
7suwa_0915
8565natumi
8565saki
8565sio
Manami4392
RinaIzumi
aiaiaiahaha
akaiayaha
akichyan325
akiminto
@fumieval
fumieval / xmonad.hs
Created September 17, 2011 14:00
Xmonad Configuration
{-# LANGUAGE TypeSynonymInstances, DeriveDataTypeable, MultiParamTypeClasses #-}
import XMonad
import XMonad.Config.Kde
import XMonad.Config.Desktop (desktopLayoutModifiers)
import XMonad.Actions.WindowGo
import XMonad.Layout.MultiToggle
import XMonad.Layout.Spiral
import XMonad.Layout.Mosaic
import XMonad.Layout.Reflect
import XMonad.Util.EZConfig
@fumieval
fumieval / A-small-practice.hs
Created September 30, 2011 11:32
Google Code Jam Japan 2011 練習問題 問題A. 数珠繋ぎ
import Data.Char
splitBy :: (t -> Bool) -> [t] -> [[t]]
splitBy p [] = []
splitBy p xs = x : (splitBy p $ dropWhile p y)
where (x, y) = break p xs
data State = ON | OFF deriving (Show, Eq)
toggle ON = OFF
toggle OFF = ON
@fumieval
fumieval / maybe.py
Created September 30, 2011 15:23
maybe monad in python
"""
Maybe monad in Python
use `Just(x)` instead of `return x`
"""
class Maybe():
def __and__(self, k): # a >>= b
if self.__class__ == __Nothing:
return Nothing
@fumieval
fumieval / xmonad.hs
Created October 24, 2011 09:16
Xmonad オススメ設定(KDE)
{-# LANGUAGE TypeSynonymInstances, DeriveDataTypeable, MultiParamTypeClasses #-}
import XMonad
import XMonad.Config.Kde
import XMonad.Config.Desktop (desktopLayoutModifiers)
import XMonad.Layout.MultiToggle
import XMonad.Util.EZConfig
import qualified XMonad.StackSet as W
@fumieval
fumieval / composite.hs
Created October 30, 2011 14:30
2つ以上の引数を持つ関数の合成
f :: Int -> Bool
f x = even x
f' :: (a -> Int) -> (a -> Bool)
f' = (f.) -- (.) :: (β→γ)→(α→β)→(α→γ) αにa、βにInt、γにBoolが当てはまる。
f'' :: (b -> (a -> Int)) -> (b -> (a -> Bool))
f'' = ((f.).) -- (.) :: (β'→γ')→(α'→β')→(α'→γ') α' に b、 β' に a->Int 、 γ'に a->Bool が当てはまる。
g = length :: [d] -> Int
0は自然数
□□■□ □■□□ ■□□■ ■□□■
□■□■ □■□□ ■■□■ ■■□■
□■□■ □■□□ ■□■■ ■□■■
□□■□ □■□□ ■□□■ ■□□■
選択公理ちゃんマジ公理
□■■□ □■■□
■□□■ ■□□□
■■■■ ■□□□
from curtana.parser import *
from curtana.functions import *
def call(f):
return TupleA() ** Return(f)
default_parser = (char("/") >> (
String("login ") >> call(twitter_auth) * Any
| String("listen ") >> call(listen_timeline) * Any
)