Courses/CS 460/Fall 2005/Homework/Xuong Tsan/Oct 1
From CSWiki
< Courses | CS 460 | Fall 2005 | Homework | Xuong Tsan
Contents |
[edit] Homework Page
Homework page is: | http://cs.calstatela.edu/~wiki/index.php/Courses/CS_460/Fall_2005/Homework/Xuong_Tsan
[edit] Count Element in the List
local
fun {Count List}
case List
of nil then 0
[] H|T then 1+{Count T}
end
end
in
{Browse {Count [2 3 5 4]}}
end
[edit] Sum a list of Integer
local
fun{SumInt List}
case List
of nil then 0
[] L|Ls then L+{SumInt Ls}
end
end
in
{Browse {SumInt [2 3 5 6 4]}}
end
[edit] Simple Tree
declare T I Y LT RT W in
T = tree(key:I value:Y left:LT right:RT)
I = seif
Y = 43
LT = nil
RT = nil
W = tree(I Y LT RT)
{Browse [T W]}

