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

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