Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.39 KB | None | 0 0
  1. class int_vec dim = object (self:'self)
  2.     val mutable _coords = Array.create dim 0
  3.  
  4.     method dot (x:'self) =
  5.       let rec innerdot sum count =
  6.         if count >= Array.length _coords then sum
  7.         else innerdot (sum + _coords.(count) * x#coords.(count)) (count + 1)
  8.       in
  9.       innerdot 0 0
  10.  
  11.     method len = sqrt (float (self#dot self))
  12.  
  13.     method coords = _coords
  14.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement