Syntax usage help


#1

If I use this function:

let check_overlap = ((x1 ,y1),ext1,(x2 ,y2),ext2) =>{
let r1 = ext1/2
let r2 = ext2/2
let maxdist = r1+r2
(maxdist < abs(x1-x2)) && (maxdist < abs(y1-y2))
};

I get an error when calcuationg maxdist ;

This expression has type int
It is not a function.

What am I doing wrong ?


#2

There are semicolons missing, so the parser interprets the 4th line as let maxdist = r1+r2(maxdist...) and complains because r2 is not a function.

This seems to compile fine:

let check_overlap = ((x1, y1), ext1, (x2, y2), ext2) => {
  let r1 = ext1 / 2;
  let r2 = ext2 / 2;
  let maxdist = r1 + r2;
  (maxdist < abs(x1 - x2)) && maxdist < abs(y1 - y2);
};