<palomer>
hrmph, we'll have to wait till one of the smarter people get on this channel to explain to us how the hashtbl works
<mfp>
jado: you're modifying the key and thus the hash value
<jado>
mfp: ok but that does not explain the Not_found exception?
<mfp>
it does
<mfp>
when you look for the key,
<mfp>
the code in Hashtbl computes its hash
<jado>
and stores the value at that address yes
<jado>
so now the hash is changed
<palomer>
but hashtbl still has it at the old address
<mfp>
yes, but the key -> value association remains in the old bucket
<jado>
but why when i print the graph the new key is printed?
<mfp>
because the association is still there
<mfp>
just in a different bucket
<palomer>
what's interesting is that Hashtbl.find hashtbl {place = (0,0); color = 0; def = true} still raises a Not_found error
<palomer>
I guess Hashtbl does a final equality check at the end
<mfp>
yes
<jado>
so one very ugly way to it would be to put the color at 0 find the list and then put back the old color?
<jado>
to do*
<palomer>
you can use objects
<palomer>
the hash value of an object is based on its address (if I remember correctly)
<mfp>
jado: either get the old value, remove & insert with the new key, or use a stable hash function with the functional interface (or using objects as palomer said)
<jado>
that's too much work; i'd rather make an ugly patch :D
<palomer>
objects are easy
* palomer
is off
<mfp>
jado: you can just tag the keys with an id, and use module H = Hashtbl.Make(struct type t = node let hash t = t.id let equal = (=) end)
lutter has joined #ocaml
<mfp>
with type node = { id : int; .... }
<jado>
yes ok i see; the id is the 'place' actually
<_andre>
jado: you could also change your key, using for example a tuple of ints which represents the place
<_andre>
heh :)
<mfp>
ah, if the key is meant to be node.place, then simply
<mfp>
module H = Hashtbl.Make(struct type t = node let hash t = Hashtbl.hash t.place let equal t1 t2 = t1.place = t2.place end)
<jado>
thanks :)
nimred has joined #ocaml
<mfp>
this way the color & def fields are ignored, and node.place effectively becomes the key, allowing you to change the former
<jado>
ok i see
ulfdoz has joined #ocaml
<jado>
got to go; thanks again
jado has quit [Remote closed the connection]
Asmadeus has joined #ocaml
nimred has quit ["leaving"]
nimred has joined #ocaml
C_Tux is now known as Camarade_Tux
Submarine has joined #ocaml
_zack1 has quit ["Leaving."]
_andre_ has joined #ocaml
_andre has quit [Read error: 104 (Connection reset by peer)]
travisbrady has joined #ocaml
willb has quit [Success]
ambient has quit [Read error: 145 (Connection timed out)]
_zack has joined #ocaml
amuck_ has joined #ocaml
julm has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
<Camarade_Tux>
I miss a List.inter(section), not having one will prevent me from writing shitty code but it's a bit annoying for small apps you'd write in 10 minutes
<kaustuv>
let inter l1 l2 = List.filter_map (fun k -> if List.exists ((=) k) l2 then Some k else None) l1 ;;
<kaustuv>
err
<kaustuv>
let inter l1 l2 = List.filter (fun k -> List.exists ((=) k) l2) l1 ;;
<Camarade_Tux>
he ;p
<Camarade_Tux>
it could be better if you sorted the lists and didn't went through all the second list each time
<Camarade_Tux>
but sure, it's easy to hack a quick version ;)
<kaustuv>
let inter l1 l2 = let ht = Hashtbl.create 1 in List.iter (fun l -> Hashtbl.add ht l ()) l2 ; List.filter (Hashtbl.mem ht) l1 ;;
<kaustuv>
O(#l1 + #l2)
<Camarade_Tux>
right, you got me here ;)
<flux>
funny thing is that it'd be quite difficult to have that in the standard library, because I'm pretty sure Hashtbl depends on Lits ;-)
<Camarade_Tux>
but my biggest trouble is getting a compare relationship for a list of attributes (represented as an association list), it should cluster "similar" lists =/
<Camarade_Tux>
or has anyone a diff program for xml files?
<Camarade_Tux>
I haven't exactly been satisfied with what I've found ;)
<kaustuv>
if you write your attributes one per line and sorted, then ordinary diff would be fine
<Camarade_Tux>
(I think the python one was bugging me because of deps)
<Camarade_Tux>
kaustuv: that's approximately what I'd like to do : sort the xml file and then use vim to diff two files, but I have troubles finding a good compare for the sort
Ppjet6 is now known as Pepe_
<Camarade_Tux>
maybe 'if more than 90% of elements in common -> 0'
<kaustuv>
seems to me that you have to first define the problem you're trying to solve carefully
<Camarade_Tux>
get the differences between the "format" produced by two versions of gobject-introspection : solution, kidnap the commiters and torture them :D
<Camarade_Tux>
(they changed the format between 0.6.2 and ... 0.6.3)
willb has joined #ocaml
<julm>
Camarade_Tux> or has anyone a diff program for xml files? <- XMLStarlet ?
<Camarade_Tux>
julm: I tried it, a diff is advertized but I couldn't find it :o
psnively has joined #ocaml
<julm>
zut :|
<julm>
"'diff' and 'patch' options are not currently implemented" /o\
<Camarade_Tux>
he :P
<kaustuv>
"I have a program that can tell whether a given Turing machine halts on all inputs, but it's a 0.1 beta release with some performance problems."
psnively has left #ocaml []
peddie_ has joined #ocaml
Skolem has quit [Read error: 110 (Connection timed out)]
<palomer>
does it support unicode?
Yoric[DT] has quit ["Ex-Chat"]
det has quit [Remote closed the connection]
peddie has quit [Read error: 113 (No route to host)]
LeCamarade is now known as LeCamarade|Away
peddie has joined #ocaml
peddie_ has quit [Read error: 60 (Operation timed out)]
_andre_ has quit ["leaving"]
Yoric[DT] has joined #ocaml
willb has quit [Read error: 110 (Connection timed out)]
Yoric[DT] has quit ["Ex-Chat"]
nominolo has joined #ocaml
<nominolo>
hm, what does this syntax mean: "foo{bar} ->;" is that a lookup just for side effect?
<nominolo>
strangely, it's not part of a pattern
Yoric[DT] has joined #ocaml
* palomer
has never seen that syntax
kblin has left #ocaml []
slash_ has joined #ocaml
yziquel has joined #ocaml
sramsay has joined #ocaml
willb has joined #ocaml
anders^^ has joined #ocaml
Submarine has quit [Client Quit]
bombshelter13_ has quit []
_zack has quit ["Leaving."]
komar_ has quit [Read error: 60 (Operation timed out)]
sramsay has quit ["Leaving"]
amuck_ has quit []
willb has quit [Read error: 110 (Connection timed out)]
ztfw has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
hkBst has quit [Remote closed the connection]
BiDOrD has quit [Read error: 110 (Connection timed out)]
BiDOrD has joined #ocaml
komar_ has joined #ocaml
komar__ has joined #ocaml
komar_ has quit [Read error: 110 (Connection timed out)]