Command-line flag to make the output random

This commit is contained in:
Mike Lynch 2025-12-24 14:11:31 +11:00
parent e0cd78f64e
commit ac9ce4d959

View File

@ -1,6 +1,7 @@
module Main (main) where module Main (main) where
import System.Random import System.Random
import System.Environment
ordinals :: [ String ] ordinals :: [ String ]
ordinals = [ ordinals = [
@ -33,7 +34,7 @@ signatures = [
] ]
offsets :: [ Int ] offsets :: [ Int ]
offsets = [ 0, 1, 1, 5, 8, 5, 20, 10, 23, 3, 3 ] offsets = reverse [ 0, 1, 1, 5, 8, 5, 20, 10, 23, 3, 3 ]
cardinals :: [ String ] cardinals :: [ String ]
cardinals = [ cardinals = [
@ -136,8 +137,7 @@ main :: IO ()
main = do main = do
gen <- newStdGen gen <- newStdGen
let roffsets = randomOffsets gen allGifts let roffsets = randomOffsets gen allGifts
print roffsets args <- getArgs
print (selectGifts roffsets) let os = if (length args) > 0 then roffsets else offsets
print (selectGifts $ reverse offsets) let tuples = zip ordinals $ selectGifts os
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