changeset 23:b4d3960af901

Define similar constructor for different element
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Tue, 30 Sep 2014 14:10:26 +0900
parents f0400c4c953f
children ae41becf41db
files similar.hs
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/similar.hs	Fri Sep 26 15:02:23 2014 +0900
+++ b/similar.hs	Tue Sep 30 14:10:26 2014 +0900
@@ -30,6 +30,9 @@
 returnS :: (Show s) => s -> Similar s
 returnS x = Similar [(show x)] x [(show x)] x
 
+returnSS :: (Show s) => s -> s -> Similar s
+returnSS x y = Similar [(show x)] x [(show y)] y
+
 -- samples
 
 generator :: Int -> Similar [Int]
@@ -38,8 +41,8 @@
 
 primeFilter :: [Int] -> Similar [Int]
 primeFilter xs = let primeList    = filter isPrime xs
-                     refactorList = filter even xs     in
-                 Similar [(show primeList)] primeList [(show refactorList)] refactorList
+                     refactorList = filter even xs    in
+                 returnSS primeList refactorList
 
 count :: [Int] -> Similar Int
 count xs = let primeCount = length xs in