changeset 2:eccc7eced616 default tip

Add foldr style diffList
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Sat, 05 Jul 2014 19:08:19 +0900
parents 0251da3f04f2
children
files diffList.hs
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/diffList.hs	Sat Jul 05 16:11:34 2014 +0900
+++ b/diffList.hs	Sat Jul 05 19:08:19 2014 +0900
@@ -31,14 +31,22 @@
 diffListLeftLength   = length $ absFromDiffList $ foldl1 (+++) diffList
 -- length $ absFromDiffList $ (++ list1) +++ (++ list2) +++ (++ list3) +++ ... +++ (++ listn)
 -- length $ absFromDiffList $ (((++ list1) +++ (++ list2)) +++ (++ list3)) +++ ... +++ (++ listn)
--- length $ absFromDiffList $ (++ list1) . (++ list2) . (++ list3) . ... . (++ listn)
--- length $ absFromDiffList $ (++ list1) . (++ list2) . (++ list3) . ... . (++ listn) -- (++ list1) = \x -> list1 ++ x
+-- length $ absFromDiffList $ ((((++ list1) . (++ list2)) . (++ list3)) . ... . (++ listn) -- (++ list1)) = \x -> list1 ++ x
 -- length $ absFromDiffList $ (++ (list1 ++ (list2 ++ (list3 ++ (...)))))
 -- length $ (++ (list1 ++ (list2 ++ (list3 ++ (...))))) []
--- length $ (list1 ++ (list2 ++ (list3 ++ (...)))) ++  [] -- right associated
 -- length $ (list1 ++ (list2 ++ (list3 ++ (...)))) ++  []
+-- length $ ((list1 ++ (list2 ++ (list3 ++ (...)))) ++  []) -- right associated
+
+diffListRightLength   = length $ absFromDiffList $ foldr1 (+++) diffList
+-- length $ absFromDiffList $ (++ list1) +++ (++ list2) +++ (++ list3) +++ ... +++ (++ listn)
+-- length $ absFromDiffList $ ((++ list1) +++ ((++ list2) +++ ((++ list3) +++ ... +++ (++ listn))))
+-- length $ absFromDiffList $ ((++ list1) . ((++ list2) . ((++ list3) . ... . (++ listn))))
+-- length $ absFromDiffList $ (++ (list1 ++ (list2 ++ (list3 ++ (...)))))
+-- length $ (++ (list1 ++ (list2 ++ (list3 ++ (...))))) []
+-- length $ ((list1 ++ (list2 ++ (list3 ++ (...)))) ++  []) -- right associated
 
 
 -- normalListRightLength -- ok
 -- normalListLeftLength  -- slowly
 -- diffListLeftLength    -- ok
+-- diffListRightLength   -- ok