table mail {
id int primary key,
from_addr varchar[50],
date datetime,
mailbox varchar[50]
}
{-# LANGUAGE DeriveDataTypeable #-} | |
-- FIXME: should we replace Data with System? | |
module Data.AutoUpdate where | |
import Control.Applicative ((<$>)) | |
import Data.IORef | |
import Control.Concurrent (threadDelay, forkIO, ThreadId, myThreadId) | |
import Control.Monad (forever) | |
import Control.Exception (throwTo, Exception, handle, fromException, throwIO, assert, SomeException) | |
import Data.Typeable (Typeable) |
{-# LANGUAGE DeriveDataTypeable, RankNTypes #-} | |
-- FIXME: should we replace Data with System? | |
module Data.AutoUpdate where | |
import Control.Applicative ((<$>)) | |
import Data.IORef | |
import Control.Concurrent (threadDelay, forkIOWithUnmask) | |
import Control.Monad (forever, void) | |
import Control.Exception (Exception, SomeException(..), handle, catches, throwIO, assert, Handler(..), mask) | |
import Data.Typeable (Typeable) |
{-# LANGUAGE ForeignFunctionInterface #-} | |
import Control.Concurrent | |
import Foreign.C.Types | |
import Foreign.C.Error | |
main :: IO () | |
main = do | |
s <- c_socket 2 1 0 | |
forkIO $ do |
(defun which (file path) | |
(catch 'loop | |
(while path | |
(if (file-exists-p (expand-file-name file (car path))) | |
(throw 'loop (message "%s" (expand-file-name file (car path)))) | |
(setq path (cdr path)))))) |
import java.util.*; | |
class Person { | |
String name; | |
int age; | |
Person (String n, int a) { | |
name = n; | |
age = a; | |
} | |
} |
% ghc hello-world.hs -L/usr/lib -L/opt/local/lib | |
Linking hello-world ... | |
Undefined symbols for architecture x86_64: | |
"_PaUtil_AllocateMemory", referenced from: | |
_Pa_Initialize in libHSbindings-portaudio-0.0.1.a(pa_front.o) | |
"_PaUtil_FreeMemory", referenced from: | |
_Pa_Initialize in libHSbindings-portaudio-0.0.1.a(pa_front.o) | |
_Pa_Terminate in libHSbindings-portaudio-0.0.1.a(pa_front.o) | |
"_PaUtil_InitializeClock", referenced from: | |
_Pa_Initialize in libHSbindings-portaudio-0.0.1.a(pa_front.o) |
import Data.Map | |
import Prelude hiding (lookup) | |
primes :: [Integer] | |
primes = sieve [2..] | |
sieve :: [Integer] -> [Integer] | |
sieve xs = sieve' xs empty | |
sieve' :: [Integer] -> Map Integer [Integer] -> [Integer] |
module Merge where | |
merge :: (Ord a) => [a] -> [a] -> [a] | |
merge xs [] = xs | |
merge [] ys = ys | |
merge l@(x:xs) r@(y:ys) | |
| x < y = x: merge xs r | |
| otherwise = y: merge l ys | |
msort :: Ord a => [a] -> [a] |
PFDS: Ex 3.1 | |
定理: | |
Leftistヒープ T において、右のパスの長さが k である場合、 | |
T のノード数 n は | |
n >= 2^(k+1) - 1 | |
である。 | |
証明:T の高さである h について帰納法で証明する。 |