summaryrefslogtreecommitdiff
path: root/demo/sum.ur
blob: 9391637ac0b4e5faaa9236aedb9d947a9c77d346 (plain)
1
2
3
4
5
6
7
8
9
10
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 {}]}<br/>
  {[sum {A = 0, B = 1}]}<br/>
  {[sum {C = 2, D = 3, E = 4}]}
</body></xml>