aboutsummaryrefslogtreecommitdiffhomepage
path: root/demo/sum.ur
blob: 483cbf0aa3fbd3391a21450a181eeebb910ea44e (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>