3 ms·
I fed it some OCaml and it worked, though the example was trivial: type point = { x: int; y : int } let manhattan_distance (a: point) (b: point) : int
by ubertaco 3y ago
I fed it some OCaml and it worked, though the example was trivial:
type point = { x: int; y : int }
let manhattan_distance (a: point) (b: point) : int =
which it completed to
type point = { x: int; y : int }
let manhattan_distance (a: point) (b: point) : int =
abs (a.x - b.x) + abs (a.y - b.y)
...which is a valid and correct OCaml definition of this method:
https://try.ocamlpro.com/#code/type'point'='$4'x:'int;'y':'int'$6!let'manhattan_distance'(a:'point)'(b:'point)':'int'=!abs'(a.x'-'b.x)'+'abs'(a.y'-'b.y)!;;!!let'origin'='$4x'='0;'y'='0$6'in!let'dest'='$4x'='2;'y'='3$6'in!Printf.printf'$($+d$('(manhattan_distance'origin'dest) https://try.ocamlpro.com/#code/type'point'='$4'x:'int;'y':'i...