Skip to content

Instantly share code, notes, and snippets.

@tanakh
tanakh / gist:8750952
Created February 1, 2014 11:20
なぜ我々はHaskellを使うのか

スタートアップ企業 Silk が、Haskellを採用した理由。

http://engineering.silk.co/post/31920990633/why-we-use-haskell

As a newly started company, we have a lot of technical decisions to make. One of the important ones is the choice of a programming language. Since we’re building a web application, this goes for both the client (i.e. the web browser) and the server.

新しく始めた会社として、我々はたくさんの技術的決定を行わなければなりません。中でも重要なのは、プログラミング言語の選択です。我々はウェブアプリケーションを作っていたので、この選択がクライアント(Webブラウザなど)とサーバの両方で必要になります。

On the client, there wasn’t much discussion. Javascript is the only viable choice, unless you want to use Flash or similar plugin-based models. But on the server, we had more freedom. Popular choices for web applications are dynamically typed languages like Ruby, Python and PHP, and statically typed languages like Java and C#.

f_xor 0x13 3 154
f_mul 0x24 0x1b 15770
f_xor 0x2e 0x39 2
f_mul 0x16 0x10 1440
f_xor 0x33 7 55
f_add 0xb 5 177
f_add 6 0xd 271
f_mul 0xc 0x3e 0x445c
f_mul 0x23 0x13 12870
f_add 0x19 8 249
20190823
20300317
20360317
20400307
20400823
20480107
20600317
20660617
20700103
20700223
#include <chrono>
int main()
{
auto start = std::chrono::system_clock::now();
// foo();
auto end = std::chrono::system_clock::now();
// elapsed time in seconds
std::chrono::duration<double> secs = end - start;
@tanakh
tanakh / gist:7764127
Created December 3, 2013 05:04
新人女子にHaskellを教え込むHaskellerの鑑 https://paiza.jp/poh/ec-campaign あなたの部署に配属された新人女子プログラマの野田さんのコードをより良いものに直してください。野田さんは実はあなたの会社の社長令嬢。効率の良いコードに書き換えて、プログラマとしてのスキルをアピールできれば昇進するチャンスです。
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed ((!))
import qualified Data.Vector.Algorithms.Intro as Intro
isort v = runST $ do
@tanakh
tanakh / gist:8321135
Last active January 2, 2016 15:09
Coeffects: Unfied static analysis of context-dependence http://tomasp.net/academic/papers/coeffects/coeffects-icalp.pdf のアブスト
Monadic Effectシステムは計算のEffectを追跡する統一された方法を提供するが、
計算がそれが実行される環境にどのように依存するかを追跡する統一された方法は提供しない。
これはモダンソフトウェアでは重要な問題になってきている。
どこで分散計算が走るのか、どのリソースを使うのか、
その他環境の提供するものをどのように使うのか。
我々は例として三つのコンテクスト依存解析を考察した。
・生存性解析
・暗黙パラメータの使用(分散計算におけるリソース使用解析と似ている)
・データフロープログラムのキャッシュ要求の計算
@tanakh
tanakh / 大型艦建造
Last active January 2, 2016 14:19
大型艦建造レシピ。 データは <http://wikiwiki.jp/kancolle/?%C2%E7%B7%BF%B4%CF%B7%FA%C2%A4#ye0c9283> から拝借。
大鳳:
- 4000/2000/5000/7000:1 52.94% (27/51)
- 7000/7000/7000/7000:1 46.88% (15/32)
- 3500/3500/6000/6000:1 38.67% (29/75)
- 7000/7000/7000/7000:20 32.08% (17/53)
- 5000/3000/5000/7000:100 21.43% (12/56)
- 7000/7000/7000/7000:100 20.19% (63/312)
- 4000/2000/5000/5000:20 19.51% (8/41)
- 4000/2000/5000/6000:100 18.37% (9/49)
- 4000/2000/5000/5500:20 18.02% (51/283)
@tanakh
tanakh / gist:8303232
Created January 7, 2014 17:40
Haskellでループみたいなん
import Control.Monad
import Control.Monad.Trans
import Control.Monad.Trans.Loop
main :: IO ()
main = do
putStrLn $ "Can you guess the number I have?"
repeatLoopT $ do
a <- liftIO $ readLn
liftIO $ putStrLn $ "You said: " ++ show a
@tanakh
tanakh / gist:8006086
Created December 17, 2013 14:51
fizzbuzz
fizzbuzz :: Int -> String
fizzbuzz n = fromMaybe (show n) $
(guard (n `mod` 3 == 0) >> pure "Fizz") <>
(guard (n `mod` 5 == 0) >> pure "Buzz")
main :: IO ()
main = forM_ [1..100] $ putStrLn . fizzbuzz
@tanakh
tanakh / gist:7862327
Created December 8, 2013 19:05
Facebook Hacker Cup Round1 C
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Text.Printf
import Data.Vector.Generic ((!))
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
main :: IO ()
main = do