<mwc>
I should have a true down there. It's like half the else branch of the conditional is being taken, and the other half isn't!
hikozaemon has quit ["Leaving..."]
<smimou>
mwc: rem_dump is evaluated *after* !dups_found it seems
<smimou>
I guess the order of evaluation for a pair of the form (f x, g y) is unspecified, so you should not rely on it
<smimou>
BTW, the "right" comparison in ocaml is = and not ==
<smimou>
(it's the same on integers but it's not semantically good to use == here)
<smimou>
yep that's it
<smimou>
# (print_string "a", print_string "b");;
<smimou>
ba- : unit * unit = ((), ())
<mwc>
So then what's == do?
<mwc>
thanks smimou, I'll just add an extra let statement to force evaluation before the tuple.
<smimou>
its physical equality (same memory location)
<mwc>
Ahah
<smimou>
but on integers it's the same as =, so it's more a matter of taste here
<mwc>
I was looking for the difference in the reference, I didn't find anything and assumed that == is equivalent to =, just a sort of lexical pacifier
<mwc>
time to grep my code :(
<smimou>
heh
<mwc>
how do = and == behave on refs?
<mwc>
== same ref I assume, but what does = mean?
<smimou>
no it's not that
<smimou>
for example "a" == "a" is false
<smimou>
because two strings are created in memory
<mwc>
ok
<smimou>
but let s = "a" in s == s is true
<mwc>
that's what I thought, "pointer" equality
<mwc>
if they reference the same object
<smimou>
yes sorry
<mwc>
okay, what about let a = ref () and b = ref (). I assume a == a is true, but what does = mean?
<smimou>
it means that they point to = things
<smimou>
# let s1 = ref "a" and s2 = ref "a" in s1 = s2;;
<smimou>
- : bool = true
<mwc>
hmm, in that case = is true
<mwc>
yeah, just did it myslef
<mwc>
I htink I understand it now, thanks
<mwc>
That's rem_dup thing was causing two different bugs in this module. One to go
Jonex has joined #ocaml
benoyst has joined #ocaml
<benoyst>
hello.
mwc has quit [Read error: 110 (Connection timed out)]
kaspersv has quit [Client Quit]
mwc has joined #ocaml
mwc has quit ["Leaving"]
shekmalhen has joined #ocaml
ookk has joined #ocaml
asbeta has joined #ocaml
ookk_ has joined #ocaml
shawn__ is now known as shawn
ookk has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
<ookk_>
can i omit the else from an if-then-else statement?
<ookk_>
im talking about an imperative function
ookk_ is now known as ookk
<asbeta>
if it returns unit then yes
<ookk>
wenn i tried to ommit the else statement it went to the row below the if-statement when the else path would have been taken
<ookk>
when*
<asbeta>
i don't understand you
<asbeta>
# if true then ();;
<asbeta>
- : unit = ()
<asbeta>
maybe you have overlapping ifs?
<ookk>
yes
<asbeta>
and outermost if have else statement?
<ookk>
and i dont think it gets the scope right
<ookk>
none have else
<asbeta>
# if false then if true then ();;
<asbeta>
- : unit = ()
<asbeta>
maybe one of your ifs doesn't return unit
<ookk>
do i have to use brackets or something?
<asbeta>
no, your program may not be type-correct
<ookk>
if primes.(n) then
<ookk>
radicals.(n) <- n;
<ookk>
if 2*n < 100000 then
<ookk>
r (2*n) (2*n);
<asbeta>
what's r type?
<ookk>
the 2nd if is within the 1st
<ookk>
its an imperative function to
<ookk>
let rec r k n =
<ookk>
primes.(n) <- false;
<ookk>
radicals.(n) <-(radicals.(n)*k);
<ookk>
if n+k < 100000 then
<ookk>
r k (n+k);
<ookk>
the problem im having is that the 2nd if-statement in p doesnt lie in the scope of the 1st if-statement
<ookk>
it breaks out of the 1st if after the first row has executed