Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (36 sloc) 1.08 KB
module Main where
import Prelude hiding (map, span, head, div)
import CGI
ms> -----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----
ms> (define (fact n)
ms> (if (= n 0)
ms> 1
ms> (* n (fact (- n 1)))))
ms> (define (make-fact-row n)
ms> (tr (td :align 'center (bold n))
ms> (td :align 'right (it (fact n)))))
ms> (define (make-fact-table n)
ms> (apply table :border 1
ms> (tr (th "n=") (th "fact"))
ms> (map make-fact-row (upto 3 n))))
ms> (font :size -1 (make-fact-table 11))
ms> -----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----
fact n =
if n == 0
then 1
else n * fact (n - 1)
makeFactRow n =
<td align="center"><b> <%= show n %> </b></td>
<td align="right"><i> <%= show (fact n) %> </i></td>
makeFactTable n =
<table border="1">
<tr><th>n=</th> <th>fact</th></tr>
<% mapM makeFactRow [3..n] %>
main =
run $ standardQuery "FactTable" $
<font size="-1"><% makeFactTable 11 %></font>
Jump to Line
Something went wrong with that request. Please try again.