Skip to content

Instantly share code, notes, and snippets.

View cesare's full-sized avatar

SAWADA Tadashi cesare

View GitHub Profile
require 'sudden_death'
module Lita
module Handlers
class Suddendeath < Handler
route /^(突然の.*)/, :sudden_death, command: false
def sudden_death(response)
response.reply response.match_data[0].sudden_death
end
@cesare
cesare / elm.md
Last active September 17, 2015 04:48

社内勉強会 Elm 篇

Elm

  • AltJS (?)
  • 関数型
  • Haskell っぽい構文
    • モナドとか出てこない
    • 遅延評価はない
  • Reactive / FRP
@cesare
cesare / polynomials.ex
Last active January 12, 2016 17:08
5.2 polynomials
defmodule Chapter5 do
def polynomial2(as, x) do
Stream.iterate(1, &(&1 * x))
|> Enum.zip(as)
|> Enum.map(fn {x, a} -> x * a end)
|> Enum.sum
end
def polynomial3(as, x) do
Enum.reverse(as) |> Enum.reduce(&(&2 * x + &1))
import Data.List ((\\))
import qualified Data.Map as Map
prune :: Ord k => Map.Map k k -> Map.Map k k
prune m = _prune m orphans
where
_prune m [] = m
_prune m os = prune $ foldl (flip Map.delete) m os
orphans = (Map.keys m) \\ (Map.elems m)
class Celebrity
attr_reader :matrix
def initialize(rows)
@matrix = rows
end
def knows?(from, to)
@matrix[from][to] == 1
end
module MaxSubseq (maxSubseq) where
import Prelude hiding (seq, sum)
data Seq = Seq { seq::[Double], sum::Double } deriving Show
instance Eq Seq where
(Seq _ x) == (Seq _ y) = x == y
instance Ord Seq where
(Seq _ x) <= (Seq _ y) = x <= y