Partial sum in Standard ML?

后端 未结 1 443
误落风尘
误落风尘 2021-01-26 13:12

Im new to functional programming and I have an assignment to compute partial sum of a list. E.g. - psum [1,1,1,1,1]; val it = [1,2,3,4,5] : int list

Here is the my cod

相关标签:
1条回答
  • 2021-01-26 14:04

    Your question is a little broad, but here's one way to sum a list. Perhaps you can adapt it to your purposes:

    fun sum [] = 0
      | sum (h::t) = h + sum t
    
    0 讨论(0)
提交回复
热议问题