pgujjula / apply-merge

Lift a binary, non-decreasing function onto ordered lists and order the output
8 stars 1 forks source link

Add visualization tool #14

Closed pgujjula closed 1 month ago

pgujjula commented 1 month ago

Add a visualization tool under Data.List.ApplyMerge.Internal that allows visualizing the pattern of generated elements in a 2-D grid:

-- | @visualize f as bs n r@ takes the parameters for an @applyMerge@ and displays what a @n@ x @n@
--   grid with a proportion @r@ of elements already generated looks like.
--
-- >>> visualize (+) [1..] [1..] 10 0.5
-- . . . . . . . . . *
-- . . . . . . . . * *
-- . . . . . . . * * *
-- . . . . . . * * * *
-- . . . . . * * * * *
-- . . . . . * * * * *
-- . . . . * * * * * *
-- . . . * * * * * * *
-- . . * * * * * * * *
-- . * * * * * * * * *
visualize :: (Ord c) => (a -> b -> c) -> [a] -> [b] -> Int -> Double -> IO ()