The program shows a numeric entry field at the bottom and a number display at the top. Whenever the user enters a number in the entry field and presses Return the factorial of that number is computed and displayed in the number display.
Here is the source code:
import Fudgets main = fudlogue (shellF "Fac" facF) facF = intDispF >==< mapF fac >==< intInputF fac 0 = 1 fac n = n * fac (n-1)
facF
) is structured as a serial composition
of three parts, using the operator
>==<
,
Notice that data flow from right to left. The parts are:
intInputF
,
mapF fac
,
an abstract fudget that applies fac
,
the factorial function, to integers received from the entry field,
and
intDispF
which displays the factorials.
fudlogue
and
shellF
on
the top level as in the previous examples.