Question: use only ocaml Provide expressions ( without type annotations ) that have the following. 1 ( a > int ) > a > int. a

use only ocaml Provide expressions (without type annotations) that have the following.
1( a > int )>a > int. a >( a >b) list >b list
3efine a function f that when used in the following expression will not produce
any type errors:
f o l d _ l e f t f ([],0)[5 ; 4 ; 3 ; 2 ; 1]
The implementation and type of fold_le are given for reference, below.
l e t r e c f o l d _ l e f t f a l = match l with
|[]> a
| h : : t > f o l d _ l e f t f ( f a h )t
4hat would you put in place for the blank such that the following code returns
44?
l e t f = fun x y z >
L i s t . f o l d _ l e f t ( fun a c c e > a c c + e +( y z ))0 x in
f [1 ; 1 ; 1 ; 1]_________4
5What would you put in place for the blank such that sublist [1]0=[] and
sublist [1; 0; 2; 3]1=[1; 0]?
l e t s u b l i s t l t =
f o l d _ r i g h t ( fun x a >____________________) l []
The implementation of fold_right is given for reference, below.
l e t r e c f o l d _ r i g h t f l a c c = match l with
|[]> a c c
| x : : x s > f x ( f o l d _ r i g h t f x s a c c )
(j) What would you put in place for the blank such that the following program
returns (10.0,40.0)?
type t a x p a y e r =
| P e r s o n of f l o a t
| Company of f l o a t
l e t t a x y =
l e t i n c o m e _ t a x a x =__________ in
match y with
| P e r s o n i > i n c o m e _ t a x i 0.1
| Company j > i n c o m e _ t a x j 0.2 in
( t a x ( P e r s o n 100.0), t a x ( Company 200.0))

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!