This holiday season, spark a lifelong love of learning. Gift Brilliant Premium
Computer Science

Functional Programming

Concept Quizzes



Consider the function below which uses fold, and an anonymous helper function.

What is the output, when x = [1; 2; 3; 4; 5; 6]?

List.fold ~f:(fun a b -> a * b) ~init:1 x ;;

Use fold or reduce to find the greatest common divisor of all the positive integers in the following file.

Consider the following snippet written in OCaml:

let list_func our_list = 
    List.fold_left ~f:(fun first second -> second::first)
                   ~init:[] our_list;;

What is the output when the following list is input:

[8;2;5;5][8; 2; 5; 5]


Problem Loading...

Note Loading...

Set Loading...