OCaml syntax error in function

I need to create a function that displays each item from a set of strings. I have done the following:

module S = Set.Make(String);;
module P = Pervasives;;
let write x = (
        P.print_string("{"); let first = true;
    S.iter (fun str -> (if first then () else P.print_string(","); P.print_string(str))) x;
    P.print_string("}");
    P.print_newline
  );;
  ^

At the end of the program (where I placed this sign), it looks like I have an error: Syntax error: operator is expected. Please help me solve this problem.

+4
source share
2 answers

I believe your syntax problem is related to let. Except for the top-level code (external module level), letmust follow in.

There are many other problems with this code, but maybe this will allow you to find the following problem :-)

A few notes:

OCaml . , first . . ( , ) .

Pervasives . "". print_string .

print_newline . . ( , .)

+5

let first = true in.

+4

All Articles