- Introduction
- A complex example

You can cut and paste the code on this page and test it on the online interpreter.

# Higher-order functions

CDuce: documentation: Tutorial: Higher-order functions

Queries Exercises

## 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 ]

Site map

CDuce: documentation: Tutorial: Higher-order functions

Queries Exercises