Last active
August 29, 2015 14:09
-
-
Save treed/e5d63c9eff65e59583a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print_table [left, right, right, right] ["Ore", "Value/m3", "Cost/m3", "Hourly Value"] (map prep_row $ sortBy most_valuable $ zip4 types values costs hourly) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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