annotate 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
rev   line source
adamc@627 1 fun sum (fs ::: {Unit}) (fold : folder fs) (x : $(mapUT int fs)) =
adamc@411 2 foldUR [int] [fn _ => int]
adamc@411 3 (fn (nm :: Name) (rest :: {Unit}) [[nm] ~ rest] n acc => n + acc)
adamc@627 4 0 [fs] fold x
adamc@411 5
adamc@411 6 fun main () = return <xml><body>
adamc@627 7 {[sum Folder.nil {}]}<br/>
adamc@627 8 {[sum (Folder.cons [#A] [()] (Folder.cons [#B] [()] Folder.nil)) {A = 0, B = 1}]}<br/>
adamc@627 9 {[sum (Folder.cons [#D] [()] (Folder.cons [#C] [()] (Folder.cons [#E] [()] Folder.nil))) {C = 2, D = 3, E = 4}]}
adamc@411 10 </body></xml>