This file contains 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
#!/usr/bin/make -f | |
CFLAGS = -O3 | |
.PHONY: all clean | |
all: main | |
main: main.c hoge.o | |
cc $(CFLAGS) -o $@ $^ |
This file contains 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 Sumlen where | |
sumList :: (Num a) => [a] -> a | |
sumList = foldr (+) 0 | |
lenList :: (Num b) => [a] -> b | |
lenList = foldr (\_ y->y+1) 0 | |
sumlenList :: (Num a, Num b) => [a] -> (a,b) | |
sumlenList = foldr (\x (y,z)->(x+y,z+1)) (0,0) |
This file contains 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 HeapTree where | |
data HTree a = HNull | HFork a (HTree a) (HTree a) deriving Show | |
hflatten :: (Ord a) => HTree a -> [a] | |
hflatten HNull = [] | |
hflatten (HFork x xt yt) = x : merge (hflatten xt) (hflatten yt) | |
merge :: (Ord a) => [a] -> [a] -> [a] | |
merge [] ys = ys |
This file contains 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
import System.Environment (getArgs) | |
data PFilter a = PFilter a (a -> Bool) | |
instance Show a => Show (PFilter a) where | |
show (PFilter s _) = "PF " ++ show s | |
mfilter :: Integral a => a -> a -> Bool | |
mfilter p x = (x `mod` p) /= 0 |
This file contains 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
/# {load def} bind def | |
/! {exch def} bind def | |
/M/moveto #/L/lineto #/RM/rmoveto #/RL/rlineto # | |
/s/stroke #/f/fill #/S/show #/CP/closepath # | |
/sudokuDict 256 dict def | |
sudokuDict begin |
This file contains 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
procedure quicksort(A,M,N); value M,N; | |
array A; integer M,N; | |
begin integer I,J; | |
if M < N then begin partition(A,M,N,I,J); | |
quicksort(A,M,J); | |
quicksort(A,I,N); | |
end | |
end quicksort |
This file contains 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
colinux> ruby uminus.rb | |
a(0) called. | |
a(-3) called. | |
c = -3 | |
d = -6 |
This file contains 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
mysequence :: (Monad m) => [m a] -> m [a] | |
mysequence xs = loop xs [] | |
where loop [] ys = return $ reverse ys | |
loop (x:xs) ys = x >>= \y -> loop xs (y:ys) |
This file contains 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> | |
struct hoge * tmp_ptr; | |
void | |
foo( void ) | |
{ | |
printf("%p\n", tmp_ptr); | |
} |
This file contains 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
#!/bin/sed -f | |
s/[05]$/& @Buzz/ | |
s/[12346789]$/& @/ | |
s/^[0-9]/@&/ | |
T | |
{ | |
:loop | |
s/@\([0-9]\)\(.* \)/\1@\2\1/ |