<randomA>
I don't understand how it would return None
<randomA>
the function lookup searches binary tree as defined in by 'a tree and looks for a matching k in its first value
lopex_ has joined #ocaml
<companion_cube>
I think you inverted the left and right cases
<spew>
randomA: there's a bug in your comparison
<spew>
I think you meant k < k'
<randomA>
ohhh
<randomA>
thanks :)
<spew>
try debugging it next time
cbarrett_ has joined #ocaml
<randomA>
i did not know of an ocaml debug
<randomA>
i have not learned print statements yet
jerith_ has joined #ocaml
AdmWiggin has joined #ocaml
tormen_ has joined #ocaml
<spew>
well you should learn them they're not hard
<randomA>
the print statements?
<randomA>
it does not print when i type into console, it just prints ()
<spew>
you can add print statements to your lookup to see where it goes when it is walking the tree
<spew>
and then figure out what you did wrong with the comparison
<randomA>
right, but the print statements need to have keyword "in" preceding it right?
Drup has quit [*.net *.split]
keep_learning has quit [*.net *.split]
tianon has quit [*.net *.split]
tormen has quit [*.net *.split]
lopex has quit [*.net *.split]
cbarrett has quit [*.net *.split]
bronsen has quit [*.net *.split]
jerith has quit [*.net *.split]
lopex_ is now known as lopex
cbarrett_ is now known as cbarrett
<pmetzger>
OCaml's print functions are just functions. Read the manual, look at examples.
Drup has joined #ocaml
<randomA>
suppose i have a binary search tree insert and it is deleting elements instead of adding to them. How would I debug this?
silver has joined #ocaml
<pierpa>
best is to not put bugs in in the first place :)
<ZirconiumX>
Or just use printfs
<ZirconiumX>
GDB works, as does ocamldebug
<companion_cube>
wait, gdb works now‽
<ZirconiumX>
I thought it did, anyway
<randomA>
But since ocaml does not let you have multiple statements I would have do like "if k = k ' then Node ((k,v), Leaf, Leaf) in Printf.printf "" in else if k < k' "?
<companion_cube>
there are multiple statements
<randomA>
but i need to use 'in'?
<companion_cube>
if k=k' then ( printf "hello"; Node((k,v),Leaf,Leaf) ) else …
<randomA>
oh interesting
<randomA>
i know why it doesn't work. but i don't know how to fix it
<randomA>
i would only debug if i didn't know why it does not work
<randomA>
It is deleting the elements, and I know it is doing that because I replace, for example, the left subtree with insert k v l. But how would I make it so that it does not replace but propogate down until it sees a Leaf?
|jbrown| has quit [Remote host closed the connection]
<randomA>
yet it needs to still go down the left subtree
<randomA>
interestingly though, even if I insert -1, it still just deletes the previous rightside node
<companion_cube>
not sure I see the problem in your snippet
AdmWiggin is now known as tianon
<randomA>
companion_cube: in the utop, when I try to insert 3 "three" it deletes the previous 2 "two"
<companion_cube>
no, your are just creating a new value
<randomA>
i think i need to check for if the left node is a Leaf before I add inser k v l
<companion_cube>
from the tree with only 1 in it
<companion_cube>
insert 2 "two" mytree <--- this doesn't modify mytree
<companion_cube>
it just creates a new tree and displays it
<randomA>
oh
cryptocat1094 has quit [Quit: WeeChat 2.2]
<randomA>
omg it works
<randomA>
thanks
<companion_cube>
that's the functional aspect! :)
<companion_cube>
you don't modify the old tree, you build a new one, and it's just a normal value
<companion_cube>
(like an integer)
ygrek has joined #ocaml
<randomA>
it is different than python
<companion_cube>
indeed
Fare has joined #ocaml
<Fare>
Hi. I have a weird deadlock early in my Lwt program that does not happen when I run my unit tests. I'm a bit stumped and printf-debugging leads me nowhere. How do I debug that?
<Fare>
the program is just doing select.
pmetzger has quit [Remote host closed the connection]
<ZirconiumX>
Fare: under what conditions?
coventry has joined #ocaml
<Fare>
ZirconiumX, early in the beginning, doing something that works in the unit tests (saving a data structure to the DB)
<Fare>
I'm obviously doing something very wrong, which is actually likely failing to do something right, and probably is a very stupid omission. Still, debugging in the dark, is, well, challenging.
<ZirconiumX>
How many threads are you using?
<coventry>
Is there a way to run an ocsigen app under ocamldebug?
<companion_cube>
Fare: are you literally using `select`?
<Fare>
Nope. I suppose the ocaml runtime is.
<companion_cube>
ah ok, lwt does use something like that, yes. I suppose you call `Lwt_main.run` with your main thread as well
<Fare>
It's possible that there is a race condition in the initialization of my DB server, that somehow ends up happily in tests but not in the executable.
<companion_cube>
I don't know how to easily debug this stuff :/
<Fare>
Yes, I run Lwt_main.run and I start the DB server.
<companion_cube>
sounds good… sorry I don't have better insights
coventry has quit [Remote host closed the connection]
<Fare>
even weirder: thread A prints a message before it puts it in the Lwt_mvar mailbox, thread B prints a message just before it Lwt_mvar.take's the message... but in the executable, it never takes it, even though in test it does it no problem.
<Fare>
I made the mailbox a global variable so there's no shadowing or aliasing possible.
<ZirconiumX>
Fare: are there any compile flag differences between your environment and the dev environment?
jnavila has quit [Ping timeout: 256 seconds]
<Fare>
not that I believe matter. I mean, my executable runs ocsigen, whereas my tests don't.
<Fare>
Now I feel like having a Lwt thread in parallel introspect the content of the mvar...
<Fare>
or even the contents of the Lwt internal tables.
<Fare>
the background thread tells me that the mvar is full...
Grommet has joined #ocaml
<randomA>
what does it mean when there are numbers after the error message saying that it expected some tree?
<randomA>
This expression has type (int * string) tree/4906975
<randomA>
such as this?
<randomA>
but an expression was expected of type ('a * 'b) tree/5908159
<companion_cube>
it means you redefined the type `tree`
<companion_cube>
but that some functions still use the old version
<companion_cube>
the numbers are the actual names of the new and old types
<Fare>
to make sure the mailbox is the same physical object, how do I get its pointer address?
<Fare>
(assuming no gc between the two debugging statements)
<companion_cube>
you can't get a pointer address, but you can use `==`
<companion_cube>
ah
<Fare>
the two objects are in different threads, and the variable is global, but maybe something affects it somehow during initialization.
<companion_cube>
I can't find anything to get the address in Obj :/
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Fare>
To build lwt from source, I tried upgrading to the newer opam 2.0.0r4, but it fails with: [ERROR] The compilation of ocaml failed at "/home/fare/.opam/opam-init/hooks/sandbox.sh build ocaml unix.cma gen_ocaml_config.ml".
steck has joined #ocaml
<steck>
hello
pmetzger has quit []
steck has quit [Ping timeout: 252 seconds]
kvda has joined #ocaml
jao has quit [Ping timeout: 240 seconds]
<Fare>
steck: hi!
jao has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kvda has joined #ocaml
gtrak has joined #ocaml
caente has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]