Skip to content

Instantly share code, notes, and snippets.

View moznion's full-sized avatar

moznion moznion

View GitHub Profile
@moznion
moznion / fib.hs
Created July 29, 2012 12:50
スタートHaskell 2 第2回目演習 フィボナッチ数列
fib :: Integer -> Integer
fib 0 = 0
fib 1 = 1
fib x = fib (x - 1) + fib (x - 2)
@moznion
moznion / collatz.hs
Created July 29, 2012 12:52
スタートHaskell 2 第2回目演習 コラッツ数列
import Data.List
import Data.Maybe
collatz :: Int -> [Int]
collatz 1 = [1]
collatz x
| even x = [x] ++ (collatz $ x `div` 2)
| otherwise = [x] ++ (collatz $ 3 * x + 1)
longestLengthOfCollatz :: Int
@moznion
moznion / functionApp.hs
Created July 29, 2012 12:53
スタートHaskell 2 第2回目演習 関数適用
g :: [a] -> [a]
g xs = tail $ tail $ tail $ tail xs
f :: [Int] -> [Int]
f xs = take 10 $ map (*3) $ filter even xs
sqrtSums :: Int
sqrtSums = (1+) $ length $ takeWhile (<1000) $ scanl1 (+) $ map sqrt [1..]
@moznion
moznion / compositeFunction.hs
Created July 29, 2012 12:54
スタートHaskell 2 第2回目演習 関数合成
g :: [a] -> [a]
g = tail . tail . tail . tail
f :: [Int] -> [Int]
f = take 10 . map (*3) . filter even
sqrtSums :: Int
sqrtSums = (1+) . length . takeWhile (<1000) . scanl1 (+) $ map sqrt [1..]
@moznion
moznion / pointFreeStyle.hs
Created July 29, 2012 12:55
スタートHaskell 2 第2回目演習 ポイントフリースタイル
f :: Int -> Int
f = (1+) . (2*)
g :: Int -> Int -> Int
g = (+) . (2*)
h :: Int -> [a] -> [a]
h = (fst .) . splitAt
i :: Ix a => (a,a) -> [a]
@moznion
moznion / gist:3599242
Created September 2, 2012 14:04
gitPullSuspender_proto
#!/usr/bin/perl
use strict;
use warnings;
use 5.012;
use WebService::Simple;
my $target_username = "plack"; # <= It's test var! Hehe. FIXME
my $target_reponame = "Plack"; # <= It's test var! Hehe. FIXME
@moznion
moznion / gist:3609964
Created September 3, 2012 15:08
Get number of pull-request
#!/usr/bin/perl
use strict;
use warnings;
use 5.012;
use WebService::Simple;
my $target_username = "USER_NAME"; # <= input your self
my $target_reponame = "REPOSITORY_NAME"; # <= input your self
@moznion
moznion / gist:3663271
Created September 7, 2012 04:51
Youtube_comment_pane_killer
div#watch7-discussion{
display: none !important
}
@moznion
moznion / gist:3663279
Created September 7, 2012 04:51
Natalie_music_comment(tweet)_pane_killer
#res {
display: none;
}
@moznion
moznion / gist:3873432
Created October 11, 2012 16:05
ruby_switcher
#!/usr/bin/env perl
use strict;
use warnings;
my $rvm_path = "~/.rvm/rubies";
`rvm list` =~ /=.*?(ruby-.*?)\s\[/;
system("$rvm_path/$1/bin/ruby @ARGV");