Curryied functions in ATS

27 views
Skip to first unread message

gmhwxi

unread,
Mar 24, 2015, 8:29:25 AM3/24/15
to ats-lan...@googlegroups.com

I said in the Intro-to-ATS book that curried functions are not commonly used
in ATS. When playing with dot-symbol overloading in ATS, I found a genuine
use of curried functions.


// print out "Hello!" 10 times
val
() = (10).foreach()(lam(i) => println! "Hello!")
// Compute 1 * 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10
val
() = (10).foldleft(TYPE{int})(1, lam(res, i) => res * (i+1))



Please see the following SATS and DATS files for more information:

https://github.com/githwxi/ATS-Postiats/blob/master/libats/ML/SATS/intrange.sats
https://github.com/githwxi/ATS-Postiats/blob/master/libats/ML/DATS/intrange.dats
Reply all
Reply to author
Forward
0 new messages