Jump to content

Functional coverage tree: Difference between revisions

m
→‎{{header|Haskell}}: (minor functor law fusions)
m (→‎{{header|Haskell}}: (minor functor law fusions))
Line 379:
columnNames = init $ tokenizeWith delimiter (head indentedLines)
in T.unlines
[ tabulation delimiter (columnNames ++ ["SHARE OF RESIDUE"])
, indentedLinesFromTree " " (showCoverage delimiter) $
withResidueShares 1.0 $
foldTree
Line 390:
weightedCoverage :: Coverage -> Forest Coverage -> Tree Coverage
weightedCoverage x xs =
let cws = ((coverage &&& weight) <$>. (rootLabel) <$> xs)
totalWeight = foldr ((+) . snd) 0 cws
in Node
Line 404:
let go fraction node =
let forest = subForest node
cws = ((coverage &&& weight) <$>. (rootLabel) <$> forest)
weights = snd <$> cws
weightTotal = sum weights
Line 465:
in T.unlines $ go "" tree
 
showCoverage :: T.Text -> T.Text -> Coverage -> T.Text
showCoverage delimiter indent x =
tabulation
delimiter
([T.append indent (name x), T.pack (showN 0 (weight x))] ++
((T.pack . showN 4) <$> ([coverage, share] <*> [x])))
 
tabulation :: T.Text -> [T.Text] -> T.Text
tabulation delimiter =
tabulation = T.intercalate "| "delimiter . zipWith (`T.justifyLeft` ' ') [31, 9, 9, 9]
 
justifyRight :: Int -> a -> [a] -> [a]
9,655

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.