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
-- 関数プログラミングの楽しみ 第1章 | |
data (Ord a) => Tree a = Null | Fork a (Tree a) (Tree a) | |
deriving (Show, Eq) | |
isEmpty :: Tree a -> Bool | |
isEmpty Null = True | |
isEmpty x = False | |
minElem :: Ord a => Tree a -> a |
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
data Color = R | B deriving(Show, Eq) | |
data Ord a => RedBlackSet a = E | T Color (RedBlackSet a) a (RedBlackSet a) | |
deriving (Show, Eq) | |
member :: Ord a => a -> RedBlackSet a -> Bool | |
member x E = False | |
member x (T _ a y b) | x < y = member x a | |
| x > y = member x b | |
| otherwise = True |
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
{-- | |
12.1 | |
1 + (2*3) の簡約可能式は | |
最も外側のものが 1+(2*3) | |
最も内側のものが (2*3) | |
(1+2)*(2+3)の簡約可能式は | |
最も外側のものが (1+2)*(2+3) | |
最も内側のものが (1+2)と(2+3)の両方 |
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
data SplayHeap a = E | T (SplayHeap a) a (SplayHeap a) deriving(Show) | |
partition pivot E = (E, E) | |
partition pivot t@(T a x b) = | |
if x <= pivot then | |
case b of | |
E -> (t, E) | |
T b1 y b2 -> if y <= pivot then | |
let (small, big) = partition pivot b2 | |
in (T (T a x b) y small, big) |
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 "kstring.h" | |
#include <stdio.h> | |
static const int MAXDIGITS = 20; | |
static const char char_table[16] | |
= {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', | |
'a', 'b', 'c', 'd', 'e', 'f'}; | |
int int2str(const int n, const int x, char *str) | |
{ |
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
#ifndef __MY_FUNCTION_HPP__ | |
#define __MY_FUNCTION_HPP__ | |
#include <boost/shared_ptr.hpp> | |
struct Holder | |
{ | |
virtual ~Holder(){}; | |
}; |
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
obj-m := listtest.o | |
INC := /usr/src/kernels/3.4.0-1.fc17.x86_64/include | |
KDIR := /lib/modules/$(shell uname -r)/build | |
PWD := $(shell pwd) | |
default: | |
$(MAKE) -C $(KDIR) M=$(PWD) modules | |
check-syntax: |
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
.PHONY: all | |
all: exec test | |
exec: exec.c | |
gcc exec.c -o exec | |
test: test.c | |
gcc test.c -o test |
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
probe kernel.function("sys_execve") { | |
printf("%s -> %s\n", thread_indent(1), probefunc()); | |
printf("%s name = %s\n", thread_indent(0), kernel_string($name)); | |
printf("%s argv[0] = %s\n", thread_indent(0), kernel_string($argv[0])); | |
printf("%s envp[0] = %s\n", thread_indent(0), kernel_string($envp[0])); | |
printf("%s envp[1] = %s\n", thread_indent(0), kernel_string($envp[1])); | |
} | |
probe kernel.function("do_execve") { | |
printf("%s -> %s\n", thread_indent(1), probefunc()); |