summaryrefslogtreecommitdiff
path: root/demo/sum.ur
blob: c8d42887adb3e832332b252ee5eaf99ddb988640 (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 fl x

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