comparison demo/sum.ur @ 627:f4f2b09a533a

demo/sum working with manual folders
author Adam Chlipala <adamc@hcoop.net>
date Sun, 22 Feb 2009 17:39:55 -0500
parents 6a0e54400805
children effa7d43aac3
comparison
equal deleted inserted replaced
626:230654093b51 627:f4f2b09a533a
1 fun sum (fs ::: {Unit}) (x : $(mapUT int fs)) = 1 fun sum (fs ::: {Unit}) (fold : folder fs) (x : $(mapUT int fs)) =
2 foldUR [int] [fn _ => int] 2 foldUR [int] [fn _ => int]
3 (fn (nm :: Name) (rest :: {Unit}) [[nm] ~ rest] n acc => n + acc) 3 (fn (nm :: Name) (rest :: {Unit}) [[nm] ~ rest] n acc => n + acc)
4 0 [fs] x 4 0 [fs] fold x
5 5
6 fun main () = return <xml><body> 6 fun main () = return <xml><body>
7 {[sum {}]}<br/> 7 {[sum Folder.nil {}]}<br/>
8 {[sum {A = 0, B = 1}]}<br/> 8 {[sum (Folder.cons [#A] [()] (Folder.cons [#B] [()] Folder.nil)) {A = 0, B = 1}]}<br/>
9 {[sum {C = 2, D = 3, E = 4}]} 9 {[sum (Folder.cons [#D] [()] (Folder.cons [#C] [()] (Folder.cons [#E] [()] Folder.nil))) {C = 2, D = 3, E = 4}]}
10 </body></xml> 10 </body></xml>