A little OCaml help

Newcap

Junior Member
Feb 25, 2016
2
0
0
I am trying to do some programming with OCaml, but I have a little trouble implementing this function:

negate : bignum -> bignum

I tried multiple things, but I have not been successful in terms of implementing the function. What do I do?
 

Newcap

Junior Member
Feb 25, 2016
2
0
0
Never mind, I have it done, but I keep getting a syntax error on one of my lines. It goes like this.
let GcompPositive (b1 : bignum) (b2 : bignum) =
let b1list = explode (toString b1) in
let b1leng = List.length b1list in
let b2list = explode (toString b2) in
let b2leng = List.length b2list in
match ((b1leng > b2leng), (b2leng > b1leng)) with
| (true, false) -> true (*we return true since we need to check if b1 is greater than b2*)
| (false, true) -> false
| (_,_) -> if (equal b1 b2) then false else Gcompare_char_by_char b1list b2list (*case when both have the same length*) ;;
Can anyone tell me what I am doing wrong here?
 
Last edited: