Randomised version works
This commit is contained in:
parent
3d80a6847d
commit
e0cd78f64e
22
app/Main.hs
22
app/Main.hs
@ -1,7 +1,6 @@
|
|||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
import System.Random
|
import System.Random
|
||||||
import Data.List
|
|
||||||
|
|
||||||
ordinals :: [ String ]
|
ordinals :: [ String ]
|
||||||
ordinals = [
|
ordinals = [
|
||||||
@ -99,12 +98,9 @@ wrapGifts (i, j, k) = map giftStr $ matchGifts (i, j, k)
|
|||||||
allGifts :: [ [ String ] ]
|
allGifts :: [ [ String ] ]
|
||||||
allGifts = map wrapGifts $ reverse signatures
|
allGifts = map wrapGifts $ reverse signatures
|
||||||
|
|
||||||
|
selectGifts :: [ Int ] -> [ String ]
|
||||||
|
selectGifts os = map (\t -> (fst t) !! (snd t)) ts
|
||||||
|
where ts = zip allGifts os
|
||||||
-- tuples :: [ ( String, String ) ]
|
|
||||||
-- tuples = zip (reverse ordinals) allGifts
|
|
||||||
|
|
||||||
|
|
||||||
concatLines :: [ String ] -> String
|
concatLines :: [ String ] -> String
|
||||||
concatLines ls = foldr (\a b -> a ++ "\n" ++ b) "" ls
|
concatLines ls = foldr (\a b -> a ++ "\n" ++ b) "" ls
|
||||||
@ -139,9 +135,9 @@ randomInts gen n = take n $ randoms gen
|
|||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
gen <- newStdGen
|
gen <- newStdGen
|
||||||
let offsets = randomOffsets gen allGifts
|
let roffsets = randomOffsets gen allGifts
|
||||||
print offsets
|
print roffsets
|
||||||
print allGifts
|
print (selectGifts roffsets)
|
||||||
|
print (selectGifts $ reverse offsets)
|
||||||
|
let tuples = zip ordinals $ selectGifts roffsets
|
||||||
-- putStrLn $ foldr (\a b -> a ++ "\n\n" ++ b) "" $ reverse $ recurseVerse tuples
|
putStrLn $ foldr (\a b -> a ++ "\n\n" ++ b) "" $ reverse $ recurseVerse tuples
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user