一个关于haskell的问题Define a function sumnegpos which takes a list of Int values and returns a pair comprising the sum of the negative and the sum of the positive integers in the list,e.g.Main> sumnegpos [2,2,-8,5,-7,-1,0,4,4](-16,17)

来源:学生作业学帮网 编辑:学帮网 时间:2024/05/27 04:54:38

一个关于haskell的问题
Define a function sumnegpos which takes a list of Int values and returns a pair comprising the sum of the negative and the sum of the positive integers in the list,e.g.
Main> sumnegpos [2,2,-8,5,-7,-1,0,4,4]
(-16,17)

sumnegpos xs = (sum negs, sum pos)
where negs = filter (0) xs