let examples = [ "integers"," (* Yes, CDuce can handle large integers ! *) let fun facto (Int -> Int) | 0 | 1 -> 1 | n -> n * (facto (n - 1)) in facto 300;; (* The tail-recursive way *) let fun facto ((Int,Int) -> Int) | (x, 0 | 1) -> x | (x, n) -> facto (x * n, n - 1) in facto (1,10000);; ";"ovfun"," type Person = FPerson | MPerson;; type FPerson = [ Name Children (Tel | Email)?];; type MPerson = [ Name Children (Tel | Email)?];; type Children = [Person*];; type Name = [ PCDATA ];; type Tel = ['0'--'9'+ '-' '0'--'9'+];; type Email = [PCDATA '@' PCDATA];; type Man = [ Sons Daughters ];; type Woman = [ Sons Daughters ];; type Sons = [ Man* ];; type Daughters = [ Woman* ];; let fun sort (MPerson -> Man ; FPerson -> Woman) [ n [(mc::MPerson | fc::FPerson)*]; _] -> let tag = match g with \"F\" -> `woman | \"M\" -> `man in let s = map mc with x -> sort x in let d = map fc with x -> sort x in <(tag) name=n>[ s d ] ;; let base : Person = [ \"Claude\" [ [ \"Véronique\" [ [ \"Ilaria\" [] ] ] \"314-1592654\" ] ] \"271-828182\" ] ;; sort base;; ";"note"," type Doc = Text;; type Text = [ (Char | (Letter+ ' '* Note))* ];; type Letter = 'a'--'z' | 'A'--'Z';; type Note = [ PCDATA ];; type Flow = [ (Char | [ PCDATA ])* ];; type Notes = [ [ PCDATA ]* ];; type Result = [ Flow Notes ];; let fun format (s : Doc) : Result = let (body,notes) = text (s,1) in [ body notes ];; let fun text ( (Text,Int) -> (Flow,Notes) ) | ([ pre::Char*? (word::Letter+ ' '* n); rem ], count) -> let (body,notes) = text (rem, count + 1) in (pre @ [word] @ body, [n] @ notes) | (body,_) -> (body, []);; let src : Doc = [ 'CDuce ' \"Frisch, Castagna, Benzaken\" ' is an XML ' \"a W3C standard\" '-friendly programming language.' ];; format src;; "; ];; let present = "
";;