rigetti / oqaml

An OCaml based implementation of a Quil QVM
Apache License 2.0
37 stars 7 forks source link

Avoid using pointer equality #3

Closed fxfactorial closed 7 years ago

fxfactorial commented 7 years ago

Not sure if this was intent, but usually isn't:

let cand x y arr =
  let bit_and ctr tar = if (ctr == 1 && tar == 1) then 1 else 0 in
  arr.(y) <-  bit_and arr.(x) arr.(y);
  arr

let cor x y arr =
  let bit_or ctr tar = if (ctr == 0 && tar == 0) then 0 else 1 in
  arr.(y) <- bit_or arr.(x) arr.(y);
  arr

let xor x y arr =
  let bit_xor ctr tar = if (ctr == tar) then 0 else 1 in
  arr.(y) <- bit_xor arr.(x) arr.(y);
  arr

== is pointer quality , you probably wanted =

jotterbach commented 7 years ago

@fxfactorial Good catch! Yes these should indeed be value comparisons and not pointer equalities.

fxfactorial commented 7 years ago

Cool, I'll open PR