Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Partial sum in Standard ML?

$
0
0
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 code so far. However my function just returns the list as it is.

 fun psum([])=[]
| ppsum2(x::L) = x::ppsum2(L);

psum([2,3,4]);  


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>