diff options
author | Mart Lubbers | 2015-04-25 12:18:42 +0200 |
---|---|---|
committer | Mart Lubbers | 2015-04-25 12:18:42 +0200 |
commit | 78636495692cc41761ad58f10b4479b6f06bdbaf (patch) | |
tree | add78181b03a26e53e210eeea7f5278492218bd1 /fp2/week2/mart/oldold/old | |
parent | Added Test (copy line from file to other file) (diff) |
finally, week2 done:)
Diffstat (limited to 'fp2/week2/mart/oldold/old')
-rw-r--r-- | fp2/week2/mart/oldold/old/Map.dcl | 10 | ||||
-rw-r--r-- | fp2/week2/mart/oldold/old/Map.icl | 19 | ||||
-rw-r--r-- | fp2/week2/mart/oldold/old/Mappen.icl | 9 | ||||
-rw-r--r-- | fp2/week2/mart/oldold/old/Random.dcl | 19 | ||||
-rw-r--r-- | fp2/week2/mart/oldold/old/Random.icl | 20 | ||||
-rw-r--r-- | fp2/week2/mart/oldold/old/ReturnEnBind.icl | 19 | ||||
-rw-r--r-- | fp2/week2/mart/oldold/old/StdIOMonad.dcl | 40 | ||||
-rw-r--r-- | fp2/week2/mart/oldold/old/StdIOMonad.icl | 93 | ||||
-rw-r--r-- | fp2/week2/mart/oldold/old/StdMaybeMonad.dcl | 9 | ||||
-rw-r--r-- | fp2/week2/mart/oldold/old/StdMaybeMonad.icl | 10 | ||||
-rw-r--r-- | fp2/week2/mart/oldold/old/StdMonad.dcl | 8 | ||||
-rw-r--r-- | fp2/week2/mart/oldold/old/StdMonad.icl | 1 |
12 files changed, 0 insertions, 257 deletions
diff --git a/fp2/week2/mart/oldold/old/Map.dcl b/fp2/week2/mart/oldold/old/Map.dcl deleted file mode 100644 index 4848e1a..0000000 --- a/fp2/week2/mart/oldold/old/Map.dcl +++ /dev/null @@ -1,10 +0,0 @@ -definition module Map
-
-//import BinTree
-import StdMaybe
-
-class Map c :: (a -> b) (c a) -> c b
-
-instance Map []
-instance Map Maybe
-//instance Map Tree
diff --git a/fp2/week2/mart/oldold/old/Map.icl b/fp2/week2/mart/oldold/old/Map.icl deleted file mode 100644 index d248c66..0000000 --- a/fp2/week2/mart/oldold/old/Map.icl +++ /dev/null @@ -1,19 +0,0 @@ -implementation module Map
-
-//import BinTree
-import StdMaybe
-import StdList
-
-class Map c :: (a -> b) (c a) -> c b
-
-instance Map [] where
- Map f [] = []
- Map f [x:xs] = [f x: Map f xs]
-
-instance Map Maybe where
- Map f Nothing = Nothing
- Map f (Just x) = Just (f x)
-
-//instance Map Tree where
-// Map f Leaf = Leaf
-// Map f (Node x l r) = Node (f x) (mapTree f l) (mapTree f r)
diff --git a/fp2/week2/mart/oldold/old/Mappen.icl b/fp2/week2/mart/oldold/old/Mappen.icl deleted file mode 100644 index faca555..0000000 --- a/fp2/week2/mart/oldold/old/Mappen.icl +++ /dev/null @@ -1,9 +0,0 @@ -module Mappen
-
-import StdEnv
-import Map
-
-Start = (
- Map ((+) 1) (Just 42),
- Map ((+) 1) [1..10])
-//Map ((+) 1) t7)
diff --git a/fp2/week2/mart/oldold/old/Random.dcl b/fp2/week2/mart/oldold/old/Random.dcl deleted file mode 100644 index 47a7c18..0000000 --- a/fp2/week2/mart/oldold/old/Random.dcl +++ /dev/null @@ -1,19 +0,0 @@ -definition module Random - - // Random number generator voor Linux gebruikers - // interface compatible met Random.dcl (helaas) - // -- mschool@science.ru.nl - -import StdFile - -:: RandomSeed - -// nullRandomSeed generates a fixed RandomSeed -nullRandomSeed :: RandomSeed - -// GetNewRandomSeed generates a good RandomSeed, using /dev/urandom -getNewRandomSeed :: !*env -> (!RandomSeed, !*env) | FileSystem env - -// Given a RandomSeed, Random generates a random number and a new RandomSeed. -random :: !RandomSeed -> .(!Int, !RandomSeed) - diff --git a/fp2/week2/mart/oldold/old/Random.icl b/fp2/week2/mart/oldold/old/Random.icl deleted file mode 100644 index b6e0768..0000000 --- a/fp2/week2/mart/oldold/old/Random.icl +++ /dev/null @@ -1,20 +0,0 @@ -implementation module Random - -import StdFile, StdList, StdMisc, StdArray, Random - -:: RandomSeed :== Int - -nullRandomSeed :: RandomSeed -nullRandomSeed = 0 - -getNewRandomSeed :: !*env -> (!RandomSeed, !*env) | FileSystem env -getNewRandomSeed env -# (ok, src, env) = sfopen "/dev/urandom" FReadData env -| not ok => abort "could not open /dev/urandom" -# (bytes, src) = sfreads src 4 - seed = foldl (\x y->(x<<8)+toInt y) 0 [c \\ c<-:bytes] -| otherwise => (seed, env) - -random :: !RandomSeed -> .(!Int, !RandomSeed) -random seed = (seed>>16 bitand 0xFFFF, seed*0x08088405+1) - diff --git a/fp2/week2/mart/oldold/old/ReturnEnBind.icl b/fp2/week2/mart/oldold/old/ReturnEnBind.icl deleted file mode 100644 index 6c3f8e4..0000000 --- a/fp2/week2/mart/oldold/old/ReturnEnBind.icl +++ /dev/null @@ -1,19 +0,0 @@ -module ReturnEnBind
-
-import StdEnv, Random
-
-Start = (r1, r2, r3, r4, nullRandomSeed, s1, s2, s3)
- where
- (r1, s1) = som2 nullRandomSeed
- (r2, s2) = som2 s1
- (r3, s3) = som2 s2
- (r4, _) = som2 s3
-
-(bind1) infix 0 :: (St s a) (a -> (St s b)) -> St s b
-(bind1) f g = uncurry g o f
-
-som2 :: (RandomSeed -> (Int,RandomSeed))
-som2 = (\s -> random s) bind1 (\a -> random (snd a))
-
-seqList1 :: [St s a] -> St s [a]
-seqList1 ...
diff --git a/fp2/week2/mart/oldold/old/StdIOMonad.dcl b/fp2/week2/mart/oldold/old/StdIOMonad.dcl deleted file mode 100644 index 375f077..0000000 --- a/fp2/week2/mart/oldold/old/StdIOMonad.dcl +++ /dev/null @@ -1,40 +0,0 @@ -definition module StdIOMonad
-
-// Deze module verpakt een aantal StdFile functies in een monadische jas
-
-import StdMonad, StdMaybeMonad
-
-:: IO a
-:: Void = Void
-:: Filemode = Lees | Schrijf
-:: Filenaam :== String
-:: *Filehandle
-
-// voer monadische I/O actie uit op de wereld:
-//doIO :: (IO a) *World -> *(a,*World)
-
-// IO is een monad:
-//instance return IO
-//instance >>= IO
-
-// lees regel van de console:
-read :: IO String
-
-/*
-// schrijf regel naar de console:
-write :: String -> IO Void
-
-// open de file met gegeven filenaam en mode:
-open :: Filenaam Filemode -> IO (Maybe Filehandle)
-
-// sluit de file met gegeven filenaam:
-close :: Filehandle -> IO Bool
-
-// bepaal of het lezen van de file klaar is:
-eof :: Filehandle -> IO Bool
-
-// lees een regel van een file:
-readline :: Filehandle -> IO (Maybe String)
-
-// schrijf een regel naar een file:
-writeline :: String Filehandle -> IO Bool*/
diff --git a/fp2/week2/mart/oldold/old/StdIOMonad.icl b/fp2/week2/mart/oldold/old/StdIOMonad.icl deleted file mode 100644 index 0338a44..0000000 --- a/fp2/week2/mart/oldold/old/StdIOMonad.icl +++ /dev/null @@ -1,93 +0,0 @@ -implementation module StdIOMonad
-
-//Deze module verpakt StdFile in een monadische jas
-
-import StdFile
-import StdMonad
-import StdMaybeMonad
-
-
-:: IO a = IO (*World Filehandle -> *(a, *World, Filehandle))
-:: Void = Void
-:: Filemode = Lees | Schrijf
-:: Filenaam :== String
-:: *Filehandle = None | FH *(Bool, Filemode, *File)
-
-toInt :: Filemode -> Int
-toInt Lees = FReadText
-toInt Schrijf = FWriteText
-
-Start world = read
-
-////voer monadische I/O actie uit op de wereld:
-//doIO :: (IO a) *World -> *(a,*World)
-//doIO (IO f) world = f (world, Closed)
-
-// IO is een monad:
-instance return IO where
- return x = IO (\w fh = (x, w, fh))
-//instance >>= IO where
-// (>>=) (IO f) g = IO(\w = let (a, w1) = f w in doIO (g a) w1)
-
-//lees regel van de console:
-read:: IO String
-read = IO (\w fh -> ("", w, fh))
-
-/*//schrijf regel naar de console:
-write:: String -> IO Void
-write s = IO (\w = (Void, write` s w))
- where
- write`:: String *World -> *World
- write` s world
- # (io, world) = stdio world
- # io = fwrites s world
- # (_, world) = fclose io
- = world
-
-//open de file met gegeven filenaam en mode:
-open:: Filenaam Filemode -> IO (Maybe Filehandle)
-open s m = IO (\w = let (f1, w1) = openfh` s m w in (f1, (w1, f1)))
- where
- openfh`:: Filenaam Filemode *World -> (Maybe Filehandle, *World)
- openfh` s m world
- # (ok, file, world) = fopen s (toInt m) world
- | ok = (Just (Open (m, file)), world)
- | otherwise = (Nothing, world)
-
-//sluit de file met gegeven filenaam:
-close:: Filehandle -> IO Bool
-close fh = IO (\w = let (b1, w1) = close` fh w in (b1, (w1, Closed)))
- where
- close`:: Filehandle *World -> (Bool, *World)
- close` Closed world = (False, world)
- close` (Open (_, file)) world = fclose file world
-
-//bepaal of het lezen van de file klaar is:
-eof:: Filehandle -> IO Bool
-eof fh = IO (\w = let (b1, w1) = eof` fh w in (b1, (w1, Closed)))
- where
- eof`:: Filehandle *World -> (Bool, *World)
- eof` Closed world = (world, False)
- eaf`(Open (_, file)) world = fclose file
-
-//lees een regel van een file:
-readline:: Filehandle -> IO (Maybe String)
-readline fh = IO (\w = let r1 = readline` fh w in r1)
- where
- readline`:: Filehandle *World -> (Maybe String, (*World, Filehandle))
- readline` Closed world = (world, Nothing)
- readline` (Open (Schrijf, _)) world = (world, Nothing)
- readline` (Open (Lees, file)) world
- # (line, file) = sfreadline file
- = (Just line, (world, Open (Lees, file)))
-
-//schrijf een regel naar een file:
-writeline:: String Filehandle -> IO Bool
-writeline s fh = IO (\w = let r1 = writeline` s fh w in r1)
- where
- writeline`:: String Filehandle *World -> (Bool, (*World, Filehandle))
- writeline` line Closed world = (False, (world, Closed))
- writeline` line (Open (Lees, file)) world = (False, (world, (Open (Lees, file))))
- writeline` line (Open (Schrijf, file)) world
- # file = fwrites line file
- = (True, (world, file))*/
diff --git a/fp2/week2/mart/oldold/old/StdMaybeMonad.dcl b/fp2/week2/mart/oldold/old/StdMaybeMonad.dcl deleted file mode 100644 index e9ebec1..0000000 --- a/fp2/week2/mart/oldold/old/StdMaybeMonad.dcl +++ /dev/null @@ -1,9 +0,0 @@ -definition module StdMaybeMonad
-
-import StdMonad
-
-:: Maybe a = Nothing | Just a
-
-instance return Maybe
-instance >>= Maybe
-instance fail Maybe
diff --git a/fp2/week2/mart/oldold/old/StdMaybeMonad.icl b/fp2/week2/mart/oldold/old/StdMaybeMonad.icl deleted file mode 100644 index 1c6277d..0000000 --- a/fp2/week2/mart/oldold/old/StdMaybeMonad.icl +++ /dev/null @@ -1,10 +0,0 @@ -implementation module StdMaybeMonad
-
-import StdMonad
-
-:: Maybe a = Nothing | Just a
-
-instance return Maybe where return x = Just x
-instance >>= Maybe where >>= (Just x) f = f x
- >>= Nothing f = Nothing
-instance fail Maybe where fail = Nothing
diff --git a/fp2/week2/mart/oldold/old/StdMonad.dcl b/fp2/week2/mart/oldold/old/StdMonad.dcl deleted file mode 100644 index cd1c654..0000000 --- a/fp2/week2/mart/oldold/old/StdMonad.dcl +++ /dev/null @@ -1,8 +0,0 @@ -definition module StdMonad
-
-class return c :: a -> c a
-class (>>=) infix 0 c :: (c a) (a -> c b) -> c b
-class fail c :: c a
-
-class Monad c | return, >>= c
-class MonadFail c | Monad, fail c
diff --git a/fp2/week2/mart/oldold/old/StdMonad.icl b/fp2/week2/mart/oldold/old/StdMonad.icl deleted file mode 100644 index db193ab..0000000 --- a/fp2/week2/mart/oldold/old/StdMonad.icl +++ /dev/null @@ -1 +0,0 @@ -implementation module StdMonad
|