Reputation: 1
my implementation so far I cant seem to understand where is the issue
let uncurry_test1 _test_ctxt =
assert_equal
uncurry f (4 3)
7
Upvotes: -1
Views: 193
Reputation: 35270
The assert_equal
function from the OUnit2 library has type,
val assert_equal :
?ctxt:test_ctxt ->
?cmp:('a -> 'a -> bool) ->
?printer:('a -> string) ->
?pp_diff:(Format.formatter -> ('a * 'a) -> unit) ->
?msg:string -> 'a -> 'a -> unit
There are only two non-keyword parameters, but you're applying it to four. I would suggest you read at least the OCaml tutorial and learn how functions are applied in OCaml. For example, the piece of code (4 3)
in OCaml means apply 4
to 3
, where "apply F to Y" means call the function F with argument X. Obviously, 4
is not a function (spoiler, it is a number), so this code doesn't make sense and raises a type error.
It is hard to guess from the information that you provided what is the type of uncurry
and what is the type of f
, but probably you meant something like this,
assert_equal 7 (uncurry f 4 3)
Which says, that we expect 7
when we uncurry the function f
and apply it to 4
and 3
.
where f
is probably curry (+)
Upvotes: 0