- AltJS (?)
- 関数型
- Haskell っぽい構文
- モナドとか出てこない
- 遅延評価はない
- Reactive / FRP
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
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 |
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
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)) |
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 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) |
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 Celebrity | |
attr_reader :matrix | |
def initialize(rows) | |
@matrix = rows | |
end | |
def knows?(from, to) | |
@matrix[from][to] == 1 | |
end |
- 集合っぽいもののそれぞれの要素にいろいろできるやつ
- http://docs.ruby-lang.org/ja/2.2.0/class/Enumerable.html
※分類は主観が入ってます
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 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 |
OlderNewer