Chapter 7. Higher-Order Functions

A higher-order function is simply a function that accepts other functions as arguments. As presented in Chapter 6, Rosetta functions are first-class items having labels, types, and values like any other declared item. Thus, it is possible to define a higher-order function simply by including a parameter in with a function type in a function’s signature. Consider the simple example of a selection function for choosing between demodulation schemes in a receiver:

   demod(dem1,dem2::< *(s::real)::real*>;
       modType::boolean; x::real)::real is
      if modType then dem1(x) else dem2(x) end if;

In this function, x is the input signal that will be demodulated and modType indicates what modulation type to select. The parameters ...

Get System-Level Design with Rosetta now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.