Question: please fast Define a function generate of type (int -> int option) -> int -> int list in hw3_lists.ml such that generate fs repeatedly applies

 please fast Define a function generate of type (int -> int

please fast

Define a function generate of type (int -> int option) -> int -> int list in hw3_lists.ml such that generate fs repeatedly applies the function F to the second argument s until we see None . (EDIT: If OCaml thinks your function has a very general type ('a -> 'a option) -> 'a -> 'a list, that's totally fine! In fact, that is encouraged.) The output list collects all the intermediate values before one sees the ending signal None. For example, generate (fun i -> None) 3 ===> [3] generate (fun i -> if i>o then Some (i-1) else None) 4 ===> [4; 3; 2; 1; 0] generate (fun i -> if i [ 2; 4; 16; 256] generate (fun i -> if i [3; 9; 27]

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!