Homeworks:AndreLivHomework

From CSWiki

Jump to: navigation, search
link title

Contents


[edit] Homework 1

%Calculate the sum of elements in list

declare Sum List List1 X L1
    fun {Sum List}      
        case List of X|L1 then X+{Sum L1}
        else 0 
    end
end

L=[3 4 9 0 2]
{Browse {Sum L}}

%the sum is : 18



%delete an element of a list
local N=[4 6 3 4 8 9 7 6 5 4]
   fun{Delete List D}
      case List of
	 H|T then
	 if D==H then {Delete T D} else H| {Delete T D} end
         [] nil then nil
     end
   end
in
   {Browse {Delete N 4}}
end