Question: write Ocaml programe to add all numbers in a list ? the solution : let rec sum list = match list with [ ] ->

write Ocaml programe to add all numbers in a list ?

the solution :

let rec sum list =

match list with

[ ] -> 0

| x:: tail -> x + (sum tail);;

let a = [2;4;5;6;1;9;10 ];;

sum a;;

question is :-Write a Ocaml Program to multiply each element in a list by 2. a= [2;4;5;6;1;9;10 ]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!