FacTst


This program illustrates how data is communicated between different parts of a Fudget program. It illustrates a simple way to combine application specific code (in this case the factorial function) with GUI elements from the Fudget library.

The program shows a numeric entry field labelled x= and a number display labelled fac(x)=. 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:


module Main where
import Fudgets

main = fudlogue (shellF "FacTst" mainF)

mainF = outFacF >==< inIntF

inIntF = "x=" `labLeftOfF` (inputDoneSP>^^=<intF)

outFacF = "fac(x)=" `labLeftOfF` intDispF >=^< fac

fac 0 = 1
fac n = n * fac(n-1)

Things to note


Next Example