Skip to content

Instantly share code, notes, and snippets.

$ cabal install gio
Resolving dependencies...
[1 of 2] Compiling SetupWrapper ( /tmp/gio-0.12.3-8865/gio-0.12.3/SetupWrapper.hs, /tmp/gio-0.12.3-8865/gio-0.12.3/dist/setup/SetupWrapper.o )
[2 of 2] Compiling Main ( /tmp/gio-0.12.3-8865/gio-0.12.3/Setup.hs, /tmp/gio-0.12.3-8865/gio-0.12.3/dist/setup/Main.o )
Linking /tmp/gio-0.12.3-8865/gio-0.12.3/dist/setup/setup ...
[1 of 2] Compiling Gtk2HsSetup ( Gtk2HsSetup.hs, dist/setup-wrapper/Gtk2HsSetup.o )
[2 of 2] Compiling Main ( SetupMain.hs, dist/setup-wrapper/Main.o )
Linking dist/setup-wrapper/setup ...
Configuring gio-0.12.3...
Building gio-0.12.3...
@pogin503
pogin503 / kuku.hs
Created April 25, 2012 14:57
九九のプログラム
-- @see http://d.hatena.ne.jp/wvogel00/20110528/1306599983
-- main = putStr $ unlines $ map show $ map (kuku 1 []) [1..9]
kuku :: Int -> [Int] -> Int -> [Int]
kuku 9 xs n = xs ++ [9*n]
kuku x xs n = kuku (x + 1) (xs ++ [n*x]) n
putKuku = putStr $ unlines $ map show $ map (kuku 1 []) [1..9]
-- @see http://d.hatena.ne.jp/kazu-yamamoto/20080215/1203060588
row = 9
;; @see http://d.hatena.ne.jp/marony0607/20111205/1323103005
;; ここの表を参考にいくつかkey-comboを作った。
(add-hook 'haskell-mode-hook
#'(lambda ()
(key-combo-define-local (kbd "," ) ", ")
;; bind function, Eq
(key-combo-define-local (kbd "=" ) '(" = " " == "))
(key-combo-define-local (kbd "::" ) " :: ")
;; Num, List, Arrow
(key-combo-define-local (kbd "+") '(" + " " ++ " " +++ "))
-- import Control.Monad
import Data.Int
-- cubed :: String -> Integer
-- cubed x = product [x, x, x]
import Data.Set
import Text.Printf (printf)
cubed :: Int -> Int
cubed x = x * x * x
@pogin503
pogin503 / my-flatten.lisp
Created May 12, 2012 05:28
lisp勉強跡地
(defun my-flatten (lst)
(cond ((atom lst) lst)
((listp (car lst))
(append (my-flatten (car lst)) (my-flatten (cdr lst))))
(t (append (list (car lst)) (my-flatten (cdr lst))))
))
@pogin503
pogin503 / leap.hs
Created May 12, 2012 16:59
leap.hs
uruu :: Int -> Bool
uruu x = (mod x 4) == 0 && (mod x 100) /= 0 || (mod x 400) == 0
-- uruu x = mod x 400 == 0
main = do
s <- getLine
if uruu (read s :: Int)
then putStrLn "YES"
else putStrLn "NO"
@pogin503
pogin503 / center.hs
Created June 12, 2012 19:01
AtCoder #001
{- http://arc001.contest.atcoder.jp/tasks/arc001_1#
他の人のを見たらそれに引きづられて丸パクリになってもうた(汗)
参考ソース: http://arc001.contest.atcoder.jp/submissions/22675#
-}
import Data.List
result = do
s <-getLine
s1 <- getLine
let countList = map (\c -> myCount c s1) "1234"
@pogin503
pogin503 / coq1.v
Created June 30, 2012 07:11
プログラミング Coq 〜 絶対にバグのないプログラムの書き方 〜
(* 1.Coqを始めよう @see http://www.iij-ii.co.jp/lab/techdoc/coqt/coqt1.html *)
(* Type: 型の型の一つ。あらゆる型のこと *)
(* Definition: 関数定義 *)
Definition id (A : Type)(x : A) : A := x.
(* 型が nat である引数 n と m を取り戻り値の型が nat である関数plus *)
Definition plus (n : nat)(m : nat) : nat := n + m.
@pogin503
pogin503 / index.html
Created July 8, 2012 07:50
console.log
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>$title</title>
$styles
</head>
<body>
<h1>$title</h1>
@pogin503
pogin503 / 40_init-flex-autopair.el
Created August 8, 2012 10:26
40_init-flex-autopair.el
;;40_init-flex-autopair.el:
;;lisp
(require 'flex-autopair)
(flex-autopair-mode 1)
;; (defun my-hook-function ()
;; (add-to-list 'flex-autopair-pairs '(?\< . ?\>)))
;; (add-hook 'c-mode-hook 'my-hook-function)