diff --git a/app/Main.hs b/app/Main.hs index cb95b3a..ecb01e9 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,7 +1,6 @@ module Main (main) where import System.Random -import Data.List ordinals :: [ String ] ordinals = [ @@ -99,12 +98,9 @@ wrapGifts (i, j, k) = map giftStr $ matchGifts (i, j, k) allGifts :: [ [ String ] ] allGifts = map wrapGifts $ reverse signatures - - - --- tuples :: [ ( String, String ) ] --- tuples = zip (reverse ordinals) allGifts - +selectGifts :: [ Int ] -> [ String ] +selectGifts os = map (\t -> (fst t) !! (snd t)) ts + where ts = zip allGifts os concatLines :: [ String ] -> String concatLines ls = foldr (\a b -> a ++ "\n" ++ b) "" ls @@ -139,9 +135,9 @@ randomInts gen n = take n $ randoms gen main :: IO () main = do gen <- newStdGen - let offsets = randomOffsets gen allGifts - print offsets - print allGifts - - --- putStrLn $ foldr (\a b -> a ++ "\n\n" ++ b) "" $ reverse $ recurseVerse tuples + let roffsets = randomOffsets gen allGifts + print roffsets + print (selectGifts roffsets) + print (selectGifts $ reverse offsets) + let tuples = zip ordinals $ selectGifts roffsets + putStrLn $ foldr (\a b -> a ++ "\n\n" ++ b) "" $ reverse $ recurseVerse tuples