gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.1 http://bit.ly/nNVIVH
ski has quit [Ping timeout: 265 seconds]
Tobu has quit [Quit: No Ping reply in 180 seconds.]
Tobu has joined #ocaml
cdidd has joined #ocaml
Tobu has quit [Remote host closed the connection]
ski has joined #ocaml
Tobu has joined #ocaml
avsm has quit [Quit: Leaving.]
NihilistDandy has joined #ocaml
emmanuelux has quit [Remote host closed the connection]
NihilistDandy has quit []
Tobu has quit [Ping timeout: 260 seconds]
Tobu has joined #ocaml
kevin01123 has joined #ocaml
kevin01123 has left #ocaml []
NihilistDandy has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
albacker has joined #ocaml
albacker has quit [Changing host]
albacker has joined #ocaml
ggherdov has joined #ocaml
Tobu has joined #ocaml
guru has joined #ocaml
guru is now known as Guest5785
<Guest5785> Printf.sprintf vs '^' -- what is more efficient ?
<adrien> printf is costly
<adrien> if you do it once, you don't really have to care unless your strings are really huge
<adrien> if you do it several times, see String.concat or use the Buffer module
<adrien> (printf can be much more readable however; can be worth it too)
<Guest5785> thx -- cost-wise , is 'String.concat' same as '^' ?
<adrien> read the documentation for String.concat, it explains the difference :-)
<Guest5785> adrien: thx a lot :)
<adrien> you're welciom
<adrien> laaag
Tobu has quit [Ping timeout: 272 seconds]
ezyang has quit [Remote host closed the connection]
Tobu has joined #ocaml
Guest5785 has quit [Quit: leaving]
xlq has joined #ocaml
NihilistDandy has quit []
avsm has joined #ocaml
Zedrikov has joined #ocaml
my_nick_was_take has joined #ocaml
my_nick_was_take has quit [Remote host closed the connection]
my_nick_was_take has joined #ocaml
my_nick_was_take has quit [Remote host closed the connection]
my_nick_was_take has joined #ocaml
my_nick_was_take has quit [Remote host closed the connection]
Zedrikov has quit [Remote host closed the connection]
Zedrikov has joined #ocaml
Zedrikov has quit [Remote host closed the connection]
hcarty has quit [Ping timeout: 252 seconds]
hcarty has joined #ocaml
Zedrikov has joined #ocaml
my_nick_was_take has joined #ocaml
my_nick_was_take has quit [Remote host closed the connection]
my_nick_was_take has joined #ocaml
my_nick_was_take has quit [Remote host closed the connection]
my_nick_was_take has joined #ocaml
Zedrikov has quit [Remote host closed the connection]
my_nick_was_take is now known as Zedrikov
my_nick_was_take has joined #ocaml
my_nick_was_take has quit [Quit: Bye all, see you next time!]
skchrko has joined #ocaml
my_nick_was_take has joined #ocaml
my_nick_was_take has quit [Remote host closed the connection]
emmanuelux has joined #ocaml
Derander has quit [Ping timeout: 246 seconds]
Derander has joined #ocaml
<pippijn> adrien: I feel your pain @lag
ggherdov has quit [Remote host closed the connection]
<pippijn> adrien: my wifi card is buggy and lags badly and spikes regularly
fschwidom has joined #ocaml
fschwidom has quit [Remote host closed the connection]
zorun has quit [Ping timeout: 240 seconds]
zorun has joined #ocaml
tlockney has quit [Ping timeout: 260 seconds]
Tobu has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
Zedrikov is now known as Cetautomatix
Cetautomatix is now known as Zedrikov84
Lor has quit [Excess Flood]
Lor has joined #ocaml
kaustuv has left #ocaml []
zorun has quit [Ping timeout: 264 seconds]
zorun has joined #ocaml
oriba has joined #ocaml
avsm has quit [Quit: Leaving.]
<xlq> Does OCaml have a built-in GCD function for ints?
emmanuelux has quit [Ping timeout: 260 seconds]
<Qrntz> xlq, I'm afraid it doesn't.
<mrvn> let gcd x y = Bigint.to_int (Bigint.gcd (Bigint.of_int x) (Bigint.of_int y)) or something
<Qrntz> or use the euclidean algorithm — it's trivial to implement
<Qrntz> http://paste.in.ua/4135/ would be the most obvious implementation
<xlq> Yeah, OK, it is pretty trivial :)
<xlq> thanks
<Qrntz> np
nimred_ has quit [Quit: leaving]
Zedrikov has joined #ocaml
Zedrikov has quit [Remote host closed the connection]
nimred has joined #ocaml
Zedrikov has joined #ocaml
Zedrikov has quit [Remote host closed the connection]
Zedrikov84 is now known as Obelix_
Zedrikov has joined #ocaml
Zedrikov has quit [Remote host closed the connection]
Zedrikov has joined #ocaml
Zedrikov has quit [Remote host closed the connection]
Zedrikov has joined #ocaml
Zedrikov has quit [Remote host closed the connection]
Obelix_ has quit [Quit: Bye all, see you next time!]
JuzorBNC has quit [Read error: Connection reset by peer]
fraggle_ has quit [Remote host closed the connection]
fraggle_ has joined #ocaml
avsm has joined #ocaml
avsm has quit [Ping timeout: 265 seconds]
avsm has joined #ocaml
lihaitao has joined #ocaml
lihaitao has quit [Quit: bed]
cdidd has quit [Remote host closed the connection]
snearch has joined #ocaml
eikke has joined #ocaml
eikke has quit [Ping timeout: 245 seconds]
eikke has joined #ocaml
albacker_ has joined #ocaml
albacker has quit [Read error: No route to host]
albacker_ is now known as albacker
albacker has quit [Changing host]
albacker has joined #ocaml
albacker is now known as eni
xlq has quit [Ping timeout: 260 seconds]
xlq has joined #ocaml
emmanuelux has joined #ocaml
apropos has joined #ocaml
xlq has quit [Ping timeout: 260 seconds]
apropos is now known as xlq
<xlq> I wanted a hash table keyed physically, so I decided to define an 'a -> int function as:
<xlq> let id x = 0 + Obj.magic x
<xlq> however, if I print the id of an object in the ocaml REPL, and then compare: (id x) = <number it printed>, it always evaluates to false.
<Lor> That's because (id x) still has the int tag bit set, while a numeric literal doesn't.
<Lor> Also, gc might move x to a new location.
<Lor> Sorry, id x _doesn't_ have the int tag bit while a numeric literal does.
<Lor> But that's only if x is heap-allocated.
<Lor> For instance (id true = 1) evaluates to true.
<mrvn> Obj.magic x doesn't set the tag but assumes it is set. so 0 + ... will add the two values and substract one tag.
<mrvn> So if x isn't int the wrong thing comes out
<xlq> OK, so maybe this isn't the best way to have a physically keyed map.
<mrvn> xlq: why not define your cmp function to use physical equality?
<xlq> Hashtbl doesn't take a cmp function.
<mrvn> module Make:
<mrvn> functor (H : HashedType) -> S with type key = H.t
<mrvn> Functor building an implementation of the hashtable structure.
<xlq> Um, missed that :P
<xlq> Thanks
<Lor> mrvn, Obj.magic doesn't assume anything, but + does.
<mrvn> you only need equality which you can do physical
<xlq> Although I still need a hash function based on physical equality
<mrvn> Lor: nah, Obj.magic assumes you know what you do.
<mrvn> xlq: I don't think that is possible. The address of an object isn't constant so you can't hash by that
<xlq> I see.
<mrvn> xlq: all entries with the same value will end up in the same bucket but you can use physical equality to keep them chained as different entries.
<xlq> Yeah.
<Lor> let id x = Obj.magic x lxor 0
<Lor> seems to work.
<mrvn> Lor: no
<Lor> It works in the sense of producing a proper int.
<xlq> Something else I could do would be to attach ids to all my types that I want to have identities.
<Lor> xlq, objects have that already.
<mrvn> # id ();;
<mrvn> - : int = 0
<mrvn> # id 0;;
<mrvn> - : int = 0
<mrvn> # id [];;
<mrvn> - : int = 0
<Lor> mrvn, what are you trying to demonstrate?
<xlq> Lor: Objects have IDs? Really?
<mrvn> Lor: that you aren't getting any kind of reliable id
<Lor> Yeah.
<flux> xlq, Oo.id
<flux> works for actual objects, not plain values :)
<Lor> mrvn, if you want to demonstrate that, you should be using heap-allocated values before and after gc.
<xlq> Oh, but just for objects.
<xlq> Yeah.
<mrvn> Lor: that too
tlockney has joined #ocaml
eikke has quit [Ping timeout: 246 seconds]
emmanuelux has quit [Quit: @+]
ggherdov has joined #ocaml
ggherdov has left #ocaml []
eikke has joined #ocaml
skchrko has quit [Quit: ChatZilla 0.9.88.2 [Firefox 11.0/20120401163544]]
eni has quit [Quit: .]
emmanuelux has joined #ocaml
shachaf has left #ocaml []
snearch has quit [Quit: Verlassend]
emmanuelux has quit [Remote host closed the connection]
emmanuelux has joined #ocaml
eikke has quit [Ping timeout: 272 seconds]
andreypopp has quit [Quit: Computer has gone to sleep.]
xlq has quit [Ping timeout: 260 seconds]