my second programming language this little baby will always
have a place in my heart if not my harddrive (or memory for
that matter). a very basic language based on lisp it seems
to be well suited for teaching some fundamental programming
topics like recursion, adt (abstract data types),
abstraction barriers, arrays,trees,and object orientated
programming. my honor's intro ics course for my major used
this language.
the one assignment I saved...;Lab #3
;written by Brent De Vries
;10/20/96
;firstly the procedure that finds the charge according to
weight
(define weight1 30)
(define weight2 50)
(define weight3 100)
(define weightcharge1 .15)
(define weightcharge2 .17)
(define weightcharge3 .22)
(define weightcharge4 4)
(define weight-charge
(lambda (w)
(cond
((< w weight1) weightcharge1)
((< w weight2) weightcharge2)
((< w weight3) weightcharge3)
(else (/ w weightcharge4)))))
;secondly the procedure that finds the charge according to
distance
(define distance1 .03)
(define distance2 400)
(define distance1charge .03)
(define distance2charge .05)
(define distance3 20)
(define distance3charge 400)
(define distance-factor
(lambda (d)
(cond
((< d distance1) distance1charge)
((< d distance2) (* d distance2charge))
(else (* distance3 (sqrt (/ d
distance3charge)))))))
;thirdly the procedure that finds if the package is
overweight
(define over! 125)
(define overweight
(lambda (w)
(cond
((> w over!) #t)
(else #f))))
;fourthly the procedure to find if the package receives a
volume discount
(define volumediscount1 1)
(define volumediscount2 0)
(define numberofletters 100)
(define volume-discount
(lambda (n w)
(cond
((equal? #t (overweight w)) volumediscount1)
((< n numberofletters) volumediscount2)
(else (> n numberofletters) (/ numberofletters
n)))))
;and then finally the procedure to add everything up and
find the cost
(define total-cost
(lambda (n w d)
(+
(* n (volume-discount n w))
(* n (weight-charge w))
(distance-factor d)))))
; and we are done;