mapp f [] = []
mapp f (x:xs) = f x ++ mapp f xs
next (a,b) = [(a,a+b),(a+b,b)] --生成正整数对
create f x = set
where set = [x] ++ (mapp f set) --无限序列构造
intpair = create next (1,1) --生成正有理数的整数对序列
trans (a,b) = a/b
rational = map trans intpair --对整数对列表应用转换函数
double [] = []
double (x:xs) = [x] ++ [-x] ++ (double xs) --生成正负有理数序列
rationals = [0] ++ double rational --所有有理数
p = take 20 rationals
main = print$ (p)