# HG changeset patch # User Daichi TOMA # Date 1390372331 -32400 # Node ID 7360fbfc7e6260685405df22b0dba8b5a6d40b0b # Parent 72cc49b616cd34278aa3be28730499429d83eeec add attrSize diff -r 72cc49b616cd -r 7360fbfc7e62 Jungle.hs --- a/Jungle.hs Wed Jan 22 15:23:36 2014 +0900 +++ b/Jungle.hs Wed Jan 22 15:32:11 2014 +0900 @@ -16,6 +16,7 @@ , drawNode , printAttributes , size +, attrSize ) where import qualified Data.Map as M @@ -222,3 +223,14 @@ subTreesSize (x:xs) = size (getNode x) + subTreesSize xs getNode x = fromJust $ M.lookup x map +-- Attributesの数を調べる +attrSize :: Node -> Int +attrSize node = M.size attr_map + subTreesSize keys + where + attr_map = getAttributesMap $ attributes node + map = getChildrenMap $ children node + keys = M.keys map + subTreesSize [] = 0 + subTreesSize (x:xs) = attrSize (getNode x) + subTreesSize xs + getNode x = fromJust $ M.lookup x map +