System Level Design with Rosetta

Chapter 7: Higher-Order Functions

Overview

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 <b class="bold">is</b>   <b class="bold">if</b> modType <b class="bold">then</b> dem1(x) <b class="bold">else</b> dem2(x) <b class="bold">end if</b>;

In this function, x is the input signal that will be demodulated and modType indicates what modulation type to select. The parameters dem1 and dem2 are functions that map real values to real values and represent the two alternative demodulation schemes. When evaluated, the function uses its boolean input to select from the two demodulation schemes. The advantage to this approach is that demodulation types need not be known when the function is developed. The designer may select a general architecture for the design while deferring specifics until a later point in the design process process. The demodulation function can be instantiated as follows:

demod(qpsk,vsb,<b class="bold">true</b>,v)

where v is the input signal and qpsk and vsb are functions that perform demodulation.

The approach becomes more powerful when combined with curried function evaluation. Using curried function evaluation, it is necessary to provide values for only...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Waveplates and Retardation Plates
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.