Skip to content

Instantly share code, notes, and snippets.

@treed
Last active August 29, 2015 14:09
Show Gist options
  • Save treed/e5d63c9eff65e59583a6 to your computer and use it in GitHub Desktop.
Save treed/e5d63c9eff65e59583a6 to your computer and use it in GitHub Desktop.
print_table [left, right, right, right] ["Ore", "Value/m3", "Cost/m3", "Hourly Value"] (map prep_row $ sortBy most_valuable $ zip4 types values costs hourly)
import Data.List
import Text.PrettyPrint.Boxes as B
print_table :: [Alignment] -> [String] -> [[String]] -> IO ()
print_table aligns titles rows = printBox $ hsep 2 B.left (map (\(align, title, col) -> vcat center2 [text title, vcat align $ map text col]) $ zip3 aligns titles (transpose rows))
left = B.left
right = B.right
center = B.center2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment