Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const vectorToInt = V => {
  2.   return parseInt(V.reverse().join(''), 2)
  3. }
  4.  
  5. const calculate = (A, B) => {
  6.   if (A === B)
  7.     return A & B
  8.   return calculate(A&B, B-1)
  9. }
  10.  
  11. const f = (A, B) => calculate(vectorToInt(A), vectorToInt(B))
  12.  
  13. console.log(f([1,0,1], [1,1,1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement