This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Data.Matrix where | |
| newtype Matrix a = Matrix { | |
| toList :: [[a]] | |
| } deriving(Eq) | |
| fromList = Matrix | |
| instance Show a => Show (Matrix a) where | |
| show (Matrix []) = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE Rank2Types #-} | |
| import Control.Applicative | |
| import Control.Lens | |
| import Control.Lens.Zipper | |
| import Data.List | |
| import Data.Tree | |
| import Data.Tree.Lens | |
| mkTree :: Int -> Tree Int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| replace :: Int -> Int -> [a] -> [a] | |
| replace i j xs | 0 <= i && i < j && j < length xs = mkHead . (:) xj . mkBody . (:) xi $ tail | |
| | null xs = [] | |
| | otherwise = xs | |
| where | |
| (mkHead, (xi:bodyTail)) = splitCps i xs id | |
| (mkBody, (xj:tail)) = splitCps (j - i - 1) bodyTail id | |
| splitCps :: Int -> [a] -> ([a] -> [a]) -> ([a] -> [a], [a]) | |
| splitCps 0 xs f = (f, xs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE OverloadedStrings #-} | |
| module Main where | |
| import Control.Concurrent | |
| import Control.Monad (forever, when) | |
| import Data.IORef | |
| import Data.Int | |
| import Data.ByteString.Char8 | |
| import System.Exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE FunctionalDependencies #-} | |
| {-# LANGUAGE TypeSynonymInstances #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| import Prelude hiding (head) | |
| import Control.Monad.Trans | |
| import Control.Monad.Trans.State | |
| type QueueT e m = StateT [e] m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| void print_array(int begin_index, int end_index, int array[]) { | |
| int i; | |
| for(i = begin_index; i <= end_index; i++) { | |
| printf("%d ", array[i]); | |
| } | |
| printf("\n"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <sys/types.h> | |
| #include <unistd.h> | |
| /* forkの動作を確認する。 */ | |
| /* 親プロセスが死ぬと、子プロセスはinitの子になる事を確認する。 */ | |
| int main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { "AWSTemplateFormatVersion" : "2010-09-09", | |
| "Description" : "test", | |
| "Mappings" : { | |
| "RegionMap" : { | |
| "us-east-1" : { "AMI" : "ami-2f726546" }, | |
| "us-west-1" : { "AMI" : "ami-84f1cfc1" }, | |
| "us-west-2" : { "AMI" : "ami-b8f69f88" }, | |
| "eu-west-1" : { "AMI" : "ami-a921dfde" }, | |
| "ap-southeast-1" : { "AMI" : "ami-787c2c2a" }, | |
| "ap-southeast-2" : { "AMI" : "ami-0bc85031" }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { "AWSTemplateFormatVersion" : "2010-09-09", | |
| "Description" : "test", | |
| "Parameters" : { | |
| "KeyPairName" : { | |
| "Type" : "String", | |
| "Description" : "key pair name" | |
| } | |
| }, | |
| "Mappings" : { | |
| "RegionMap" : { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "code.google.com/p/go-tour/wc" | |
| "strings" | |
| ) | |
| func WordCount(s string) map[string]int { | |
| var wc map[string]int = make(map[string]int) | |
| for _, key := range strings.Fields(s) { |