From 8a40514984740b91b35343fc1e22c0cacec869b7 Mon Sep 17 00:00:00 2001 From: Rnhmjoj Date: Tue, 14 Oct 2014 18:09:58 +0200 Subject: [PATCH] Move module location --- Diceware.hs => Alea/Diceware.hs | 4 ++-- List.hs => Alea/List.hs | 10 +++++----- Random.hs => Alea/Random.hs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) rename Diceware.hs => Alea/Diceware.hs (94%) rename List.hs => Alea/List.hs (69%) rename Random.hs => Alea/Random.hs (92%) diff --git a/Diceware.hs b/Alea/Diceware.hs similarity index 94% rename from Diceware.hs rename to Alea/Diceware.hs index 7d6c42e..1a5ddc5 100644 --- a/Diceware.hs +++ b/Alea/Diceware.hs @@ -1,7 +1,7 @@ -module Diceware where +module Alea.Diceware where import qualified Data.Map as Map -import List +import Alea.List -- Diceware dictionary type type Diceware = Map.Map Int String diff --git a/List.hs b/Alea/List.hs similarity index 69% rename from List.hs rename to Alea/List.hs index 2225f99..b27779c 100644 --- a/List.hs +++ b/Alea/List.hs @@ -1,16 +1,16 @@ -module List where +module Alea.List where -- Remove the nth element of a list. (0-indexed) -- RemoveAt 2 "abc" == ('c', "ab") removeAt :: Int -> [a] -> (a, [a]) removeAt n xs = (xs !! n, take n xs ++ drop (n+1) xs) --- Split a string into a list of strings +-- Split a list into a list of lists -- ex. split "ab,cd,ef" ',' == ["ab","cd","ef"] -split :: String -> Char -> [String] -split [] _ = [""] +split :: (Eq a) => [a] -> a -> [[a]] +split [] _ = [[]] split (c:cs) delim - | c == delim = "" : rest + | c == delim = [] : rest | otherwise = (c : head rest) : tail rest where rest = split cs delim diff --git a/Random.hs b/Alea/Random.hs similarity index 92% rename from Random.hs rename to Alea/Random.hs index 53cbb1b..4902c83 100644 --- a/Random.hs +++ b/Alea/Random.hs @@ -1,7 +1,7 @@ -module Random where +module Alea.Random where import System.Random -import List +import Alea.List -- Get n random numbers from the list ys randPick :: (Eq a, RandomGen g) => [a] -> Int -> g -> ([a], g)