Reputation: 342
When I compile and Execute this piece of code. It prints nothing.
let main list =
let rec xyz list =
match list with
|[]->[]
|m::body ->
begin
print_int m;
xyz body
end
in xyz
let h = main [1;2;3]
If xyz is used outside of main is working without any error and printing 1 2 and 3
Upvotes: 0
Views: 99
Reputation: 18892
Compiling your code with all warning enabled yields the following warning:
1 | let main list =
^^^^
Warning 27 [unused-var-strict]: unused variable list.
And indeed, the argument list
is unused by main
since in
let main list =
let rec xyz list =
...
in
xyz
you are returning the function xyz
without applying it.
Upvotes: 2