一个关于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/11/17 07:43:42
一个关于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)
一个关于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)
一个关于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