Reputation: 130
This part of my code always shows me some syntx error: operator expected in the ocaml REPL. The error is on the let
of the line "let rec projected ...". What might it be? conditions
is defined as a string list
and aTable
is (string list * string list* (string list) list)
let project (conditions, aTable)=(
let trueFalseList = match aTable with
_,cols,_ -> dataMatcher(cols, conditions)
let rec projected (aTable, trueFalseList) = match aTable with
name,[],[] -> name,[],[]
|name,cols,[] -> newLineMaker ((List.hd cols), trueFalseList)::projected(name,(List.tl cols),[])
|name,cols,vals -> newLineMaker ((List.hd vals), trueFalseList)::projected(name,cols,(List.tl vals))
)
Upvotes: 1
Views: 83
Reputation: 66818
The lines typed into an OCaml REPL in essence form an OCaml module. At the outermost level of a module you can have
let name = value
to define a global named value of the module.
In your case, you have let project (conditions, aTable) = value
. In other words, you're defining a function project
that takes a pair of values as its parameter.
In any places other than the outermost level of a module, there are no global names. So every let
must be followed by in
. This is the case in the definition of your project
function, and is what the interpreter is complaining about. It is expecting to see in
, or a continuation of the expression (i.e., an operator of some sort).
It's not clear what your function project
is supposed to return. What is the type of project
as a whole?
Upvotes: 2