Skip to content

Instantly share code, notes, and snippets.

View ikedaisuke's full-sized avatar

Ikegami Daisuke ikedaisuke

View GitHub Profile
-- http://atnd.org/events/46727
-- https://gist.github.com/cojna/0918920c7a246961227b
import Control.Monad.State
import qualified Data.Map as M
type Memo = M.Map Int Integer
add :: Int -> Integer -> State Memo ()
add k v = do s <- get
@ikedaisuke
ikedaisuke / gist:6853730
Created October 6, 2013 12:54
"^a$z" は数万回テスト回したんですが見つけられませんでした…犬も歩けば棒にあたる式テストで反例を探しています。正規表現に関する知識は一切実装していません。
-- a lightweight pxeger with QuickCheck2 in Haskell
-- usage:
-- 1) find an example which satisfies the regex "a":
-- ghci> check (mkRegex "a")
-- *** Failed! Falsifiable (after 50 tests and 5 shrinks):
-- "a"
-- check tries at most 100 tests. here, we found within 50 tests.
-- 2) search more instances with the regex "a.b"
-- ghci> checkDeep 1000 (mkRegex "a.b")
-- *** Failed! Falsifiable (after 316 tests and 7 shrinks):
@ikedaisuke
ikedaisuke / gist:6748225
Created September 29, 2013 00:58
グラフ理論の教科書、というよりは、僕の好きな本の中でグラフのことが書いてある本一覧
<html>
<p>
良い本、普通の本は他の人が挙げると思うので、他の人が挙げなさそうなものをできるだけ選んでみます。
</p>
<hr><pre>
Bernhard Korte and Jens Vygen,
"Combinatorial Optimization, theory and algorithms",
Springer
</pre>
<p>

Haskell golf @ すごいHaskell読書会in大阪 8th meeting

2013-05-09

@ikegami__

問題

前回の出題にある通りです。

あらためて書くと、標準入力から与えられる文字列のなかに文字@が何回現れるかを数えてその個数を標準出力せよ、という問題でした。

@ikedaisuke
ikedaisuke / gist:5335869
Last active December 15, 2015 22:49
すごい Haskell 読書会 in 大阪 #8 における課題です。

すごいHaskell読書会 in 大阪 #8 課題

提出者 いけがみ @ikegami__

変更:ネタバレはよくないことに気がついたので、当初書いていたいくつかの問題は削除します。

Haskell code golf に挑戦しよう!

Code golf とは、与えられた仕様を満たす、できるだけ短いプログラムをつくることです。言語はなんでもよいのですが、今回はすごい Haskell を使いましょう。

プログラムを書いたファイルを Foo.hs としたとき、Unix ならば

@ikedaisuke
ikedaisuke / gist:5330979
Last active December 15, 2015 22:09
half-finished translation of tune's slides "Lens で Haskell をもっと格好良く!" it's just only half of each header of slide yet. here is the original source: http://www.slideshare.net/itsoutoftunethismymusic/ekmett-17955009

Title

A gentle introduction to write an attractive Haskell program with lens

Author

ちゅーん tune

Date

2013-03-27 すごいHaskell読書会 in 大阪 #7 の課題について
@yashigani さんの出題した課題の設計方針を書きます
問題はこちら:
https://gist.github.com/yashigani/5231928
上記資料の一番下に課題があります。
転載:
-----
@ikedaisuke
ikedaisuke / gist:4175351
Created November 30, 2012 11:54
Some answers of the homework in the slides
-- http://koko-u.github.com/haskell_book_reading/#25
import Data.Char (toUpper, intToDigit, isSpace)
import Data.List (isInfixOf, nub)
import Numeric (showIntAtBase)
upperCase :: String -> String
upperCase = map toUpper
removeSpaces :: String -> String
@ikedaisuke
ikedaisuke / Homework.hs
Created November 30, 2012 10:58
Answers of the homework in the slides
-- http://www.slideshare.net/yashigani/haskell-in/19
module Homework where
import Data.List(foldl')
myNull :: [a] -> Bool
myNull [] = True
myNull _ = False
@ikedaisuke
ikedaisuke / Noricoco.agda
Created May 30, 2012 10:34
@noricoco gives an exercise.
module Noricoco where
-- Hello! See also
-- http://togetter.com/li/312309
open import Data.Empty using (⊥-elim)
open import Data.Nat using (_≟_; ℕ)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Relation.Binary.PropositionalEquality using (_≡_)
open import Relation.Nullary using (yes; no)