[Fudgets Home Page]

A program to test the factorial function

Version 2, with improved layout


This program shows how to use layout combinators to improve the visual appearance of a Fudget program.

[Your browser doesn't support fupplets. Here is a window dump instead:]

[Window dump of the Factorial example, version 2]

We have made the previous Factorial function example more self documenting by adding labels to the entry field and the output display. We have also changed the order of the two parts: the entry field is now above the display.

Here is the source code:

import Fudgets

main = fudlogue (shellF "Fac" facF)

facF = placerF (revP verticalP) (
        ("x! =" `labLeftOfF` intDispF) >==<
        mapF fac >==<
        ("x =" `labLeftOfF` intInputF))

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

Things to note


  • Next Example
  • Previous Example
  • Back to the Example list