demo10.servlet
;; this servlet shows another way to create
;; lists and tables
(servlet ()
{
list/table demo
Here is a servlet generate list
[(lis {class="a"}
`(mon tue wed thu fri sat sun)
)]
sun | mon | tue |
wed | thu | fri |
sat |
[(trs {class= "b"}
`(
( 9 - - - - - - )
(10 gym - gym - - - )
)
)
]
}
)
demo11.servlet
(servlet (a)
;; this servlet just squares numbers....
(case a
((#null) {add ?a=11 to the URL please})
(else
{the square of [a] is [(* a a)]}
)))
demo12.servlet
(servlet (a b)
;; compute area and perimeter of a right triangle
;; with sides of length a and b
(case a
((#null) {Enter ?a=3&b=4 at the end of the URL})
(else
{The area of a triangle with sides [a] and [b]
is [(* a b 0.5)] and the perimeter is
[(+ a b (sqrt (+ (* a a) (* b b))))]}
)))(servlet (a b)
(case a
((#null) {you know...})
(else
(let ((hyp
(sqrt (+ (* a a) (* b b)))
))
{The perimeter is [(+ a b hyp)]}
))))
demo13.servlet
(servlet (a b c)
(case a
((#null) {enter a,b,c})
(else
(let*
((p (+ a b c))
(s (/ p 2.0))
(area (sqrt (* s (- s a) (- s b) (- s c))))
)
{The area of an [a],[b],[c] triangle is [area]}
))))
demo14.servlet
(tryCatch
(servlet (a b c)
(case a
((#null) {Enter a,b,c})
(else
(define p (+ a b c))
(define s (/ p 2))
(define area (sqrt (* s (- s a) (- s b) (- s c))))
{The area of a [a],[b],[c] triangle is [area]}
)
)
)
(lambda(e)
{There was an error:[e]. Be careful with my servlet}
)
)