summaryrefslogtreecommitdiff
path: root/demo/sum.ur
blob: 22a21d8b0eeb4ff82be0bcc869951415213119d2 (plain)
1
2
3
4
5
6
7
8
9
fun sum (fs ::: {Unit}) (x : $(mapUT int fs)) =
    foldUR [int] [fn _ => int]
    (fn (nm :: Name) (rest :: {Unit}) [[nm] ~ rest] n acc => n + acc)
    0 [fs] x

fun main () = return <xml><body>
  {[sum {A = 0, B = 1}]}<br/>
  {[sum {C = 2, D = 3, E = 4}]}
</body></xml>