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.38 KB | None | 0 0
  1. class int_vec dim =
  2. object(self)
  3.     val mutable coords = Array.create dim 0
  4.    
  5.     method dot (x:int_vec) =
  6.       let rec innerdot sum count =
  7.         if count >= Array.length coords then sum
  8.         else innerdot (sum + coords.(count) * x#coords.(count)) (count + 1)
  9.       in innerdot 0 0
  10.      
  11.     method len = sqrt(dot self)
  12.          
  13.     method coords = coords
  14. end
  15. ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement