Home

About

Advanced Search

Browse by Discipline

Scientific Societies

E-print Alerts

Add E-prints

E-print Network
FAQHELPSITE MAPCONTACT US


  Advanced Search  

 
(a) let sumUp s Nil = Cons s Nil sumUp s (Cons x xs) = Cons s (sumUp (s+x) xs)
 

Summary: Exercise 1
(a) let sumUp s Nil = Cons s Nil
sumUp s (Cons x xs) = Cons s (sumUp (s+x) xs)
in sumUp 0 (Cons 1 (Cons 2 Nil))
­­ Rule 1
let sumUp = \x1 x2 ­>
case (x1,x2) of
(s,Nil) ­> Cons s Nil
(s,(Cons x xs)) ­> Cons s (sumUp (s+x) xs)
in sumUp 0 (Cons 1 (Cons 2 Nil))
­­ Rule 3
let sumUp = \x1 ­> \ x2 ­>
case (x1,x2) of
(s,Nil) ­> Cons s Nil
(s,(Cons x xs)) ­> Cons s (sumUp (s+x) xs)
in sumUp 0 (Cons 1 (Cons 2 Nil))
­­ Rule 5
let sumUp = \x1 ­> \ x2 ­>
match (s,Nil) (x1,x2) (Cons s Nil)
(match (s,(Cons x xs)) (x1,x2) (Cons s (sumUp (s+x) xs)) bot)

  

Source: Ábrahám, Erika - Fachgruppe Informatik, Rheinisch Westfälische Technische Hochschule Aachen (RWTH)

 

Collections: Computer Technologies and Information Sciences