Skip to content

Instantly share code, notes, and snippets.

View kakkun61's full-sized avatar
🚂
Choo-choo

Kazuki Okamoto kakkun61

🚂
Choo-choo
View GitHub Profile
@kakkun61
kakkun61 / MemoFib.hs
Last active December 12, 2015 00:09
すごい Haskell 読書会 in 大阪 #4 用に考えた。Data.Map 使ってメモ化したフィボナッチ数関数。
module MemoFib (
memoFib
) where
import qualified Data.Map as M
memoFib :: (Ord k, Num k, Num a) => k -> a
memoFib k = snd $ memoFib' (M.fromList [(0,0),(1,1)]) k
memoFib' :: (Ord k, Num k, Num a) => M.Map k a -> k -> (M.Map k a, a)
@kakkun61
kakkun61 / Main.hs
Last active December 12, 2015 00:09
すごい Haskell 読書会 in 大阪 #4 村主さんの問題への解答
import Parupunte
import Prelude hiding ((+), (*))
import qualified Prelude as P
main = do
print $ (2+8)*(3+7) -- should print 37
print $ (2 P.+ 8) P.* (3 P.+ 7)
@kakkun61
kakkun61 / texpdf
Last active October 13, 2015 22:18
LaTeX で PDF 作るときによく打つコマンド
#! /bin/bash
if [ $# -ne 1 ]; then
echo 'Usage: texpdf file(w/o extension)'
exit 1
fi
platex $1.tex && platex $1.tex && dvipdfm -p a4 $1.dvi
if [ -e $1.dvi ]; then
rm $1.dvi
@kakkun61
kakkun61 / Ex1.hs
Created November 30, 2012 11:39
すごい Haskell 読書会 2日目
upperCase :: Char -> Char
upperCase c =
let l = length ['a'..'z']
t = length $ takeWhile (/=c) ['a'..'z']
in
if l == t
then c
else ['A'..'Z'] !! t
upperString :: String -> String
@kakkun61
kakkun61 / gist:3689694
Created September 10, 2012 08:36
Fibonacci number 31st
a = 0,
b = 1,
for (i = 0; i < 31 - 2; i = i + 1)
tmp = a,
a = b,
b = tmp + b.,
puts(b).
@kakkun61
kakkun61 / gist:3187108
Created July 27, 2012 09:34
Fibonacci number
makeFib = func()
inner a = 0,
inner b = 1,
func()
rtn = a,
a = b,
b = rtn + b,
rtn..,
fib = makeFib(),
for (i = 0; i < 50; i = i + 1)
@kakkun61
kakkun61 / gist:3181068
Created July 26, 2012 08:50
Functional Composition in C++ ver. 3
#include<iostream>
#include<functional>
#include<cmath>
using namespace std;
using namespace std::tr1;
template<typename Param, typename Result>
class Function {
private:
@kakkun61
kakkun61 / gist:3148354
Created July 20, 2012 02:47
Functional Composition in C++ ver. 2.2
#include<iostream>
#include<functional>
#include<cmath>
using namespace std;
using namespace std::tr1;
template<typename Param, typename Result>
class Function {
public:
@kakkun61
kakkun61 / gist:3148173
Created July 20, 2012 01:52
Functional Composition in C++ ver. 2.1
#include<iostream>
#include<functional>
#include<cmath>
using namespace std;
using namespace std::tr1;
template<typename Param, typename Result>
class Function {
public:
[color]
ui = true
[alias]
log-graph = log --graph --decorate --abbrev-commit --all
[core]
editor = emacs
#editor = nano
[credential]
helper = cache
[gui]