CDuce: documentation: Tutorial: Higher-order functions
Introduction
TO BE DONE
A complex example
Rewrite in order not to introduce new type declarations
type Program = <program>[ Day* ] type Day = <date day=String>[ Invited? Talk+ ] type Invited = <invited>[ Title Author+ ] type Talk = <talk>[ Title Author+ ] type Author = <author> String type Title = <title> String let patch_program (p :[Program], f :(Invited -> Invited) & (Talk -> Talk)):[Program] = xtransform p with (Invited | Talk) & x -> [ (f x) ] let first_author ([Program] -> [Program]; Invited -> Invited; Talk -> Talk) | [ Program ] & p -> patch_program (p,first_author) | <(k)>[ t a _* ] -> <(k)>[ t a ]
CDuce: documentation: Tutorial: Higher-order functions