comparison diffList.hs @ 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
comparison
equal deleted inserted replaced
1:0251da3f04f2 2:eccc7eced616
29 -- length $ (list1 ++ (list2 ++ (list3 ++ ... ++ listn))) -- right associated 29 -- length $ (list1 ++ (list2 ++ (list3 ++ ... ++ listn))) -- right associated
30 30
31 diffListLeftLength = length $ absFromDiffList $ foldl1 (+++) diffList 31 diffListLeftLength = length $ absFromDiffList $ foldl1 (+++) diffList
32 -- length $ absFromDiffList $ (++ list1) +++ (++ list2) +++ (++ list3) +++ ... +++ (++ listn) 32 -- length $ absFromDiffList $ (++ list1) +++ (++ list2) +++ (++ list3) +++ ... +++ (++ listn)
33 -- length $ absFromDiffList $ (((++ list1) +++ (++ list2)) +++ (++ list3)) +++ ... +++ (++ listn) 33 -- length $ absFromDiffList $ (((++ list1) +++ (++ list2)) +++ (++ list3)) +++ ... +++ (++ listn)
34 -- length $ absFromDiffList $ (++ list1) . (++ list2) . (++ list3) . ... . (++ listn) 34 -- length $ absFromDiffList $ ((((++ list1) . (++ list2)) . (++ list3)) . ... . (++ listn) -- (++ list1)) = \x -> list1 ++ x
35 -- length $ absFromDiffList $ (++ list1) . (++ list2) . (++ list3) . ... . (++ listn) -- (++ list1) = \x -> list1 ++ x
36 -- length $ absFromDiffList $ (++ (list1 ++ (list2 ++ (list3 ++ (...))))) 35 -- length $ absFromDiffList $ (++ (list1 ++ (list2 ++ (list3 ++ (...)))))
37 -- length $ (++ (list1 ++ (list2 ++ (list3 ++ (...))))) [] 36 -- length $ (++ (list1 ++ (list2 ++ (list3 ++ (...))))) []
38 -- length $ (list1 ++ (list2 ++ (list3 ++ (...)))) ++ [] -- right associated
39 -- length $ (list1 ++ (list2 ++ (list3 ++ (...)))) ++ [] 37 -- length $ (list1 ++ (list2 ++ (list3 ++ (...)))) ++ []
38 -- length $ ((list1 ++ (list2 ++ (list3 ++ (...)))) ++ []) -- right associated
39
40 diffListRightLength = length $ absFromDiffList $ foldr1 (+++) diffList
41 -- length $ absFromDiffList $ (++ list1) +++ (++ list2) +++ (++ list3) +++ ... +++ (++ listn)
42 -- length $ absFromDiffList $ ((++ list1) +++ ((++ list2) +++ ((++ list3) +++ ... +++ (++ listn))))
43 -- length $ absFromDiffList $ ((++ list1) . ((++ list2) . ((++ list3) . ... . (++ listn))))
44 -- length $ absFromDiffList $ (++ (list1 ++ (list2 ++ (list3 ++ (...)))))
45 -- length $ (++ (list1 ++ (list2 ++ (list3 ++ (...))))) []
46 -- length $ ((list1 ++ (list2 ++ (list3 ++ (...)))) ++ []) -- right associated
40 47
41 48
42 -- normalListRightLength -- ok 49 -- normalListRightLength -- ok
43 -- normalListLeftLength -- slowly 50 -- normalListLeftLength -- slowly
44 -- diffListLeftLength -- ok 51 -- diffListLeftLength -- ok
52 -- diffListRightLength -- ok