<twobitsprite>
how should one convert a char to a string? I see String.create, but there has to be some other way...
<pnou>
that's what i use
<twobitsprite>
I see... right on
<pnou>
well i define a string_of_char function using String.create
<twobitsprite>
interesting... there a lot of things missing the from the standard lib that make me wonder...
mlh_ has joined #ocaml
<pnou>
this function is in the extlib
<pnou>
ExtLib is a project aiming at providing a complete - yet small - standard library for the OCaml programming langage.
<twobitsprite>
is there an easy way to have a bi-directional mapping?
Amorphous has quit [Read error: 110 (Connection timed out)]
<twobitsprite>
n/m, I don't think I need one after all...
<pnou>
what about using two maps (combined in a new functor)?
Amorphous has joined #ocaml
<twobitsprite>
ack... I still haven't taken the time to grok modules and functors... maybe I'll do that
mrsolo has quit [Read error: 104 (Connection reset by peer)]
sethk has joined #ocaml
descender has quit [Remote closed the connection]
pango_ has joined #ocaml
pango has quit [Read error: 110 (Connection timed out)]
threeve has quit []
Nutssh has joined #ocaml
vezenchio has joined #ocaml
Submarine has joined #ocaml
ski has joined #ocaml
pango_ has quit [Remote closed the connection]
pango has joined #ocaml
Skal has joined #ocaml
descender has joined #ocaml
smimou has joined #ocaml
m3ga has joined #ocaml
Revision17 has joined #ocaml
mlh_ has quit [Client Quit]
revision17_ has quit [Read error: 110 (Connection timed out)]
<mellum>
Hm, the 50-line function I just wrote compiled without a type error. I guess that means it must be totally bogus.
<haelix>
mellum: :-)
<haelix>
mellum: and was its computed type the type you expected it shoudl have ?
<mellum>
haelix: yes. How confusing.
<haelix>
mellum: sounds to me that you have self-confidence problems
<mellum>
well, it just doesn't match my experience :)
<haelix>
it's the first time it happened to you ?
<mellum>
well, usually there's at least one typo or so every few lines, which then gets caught by the type checker... misordering arguments or something
<jynxzero>
wootoo who do what you don't dare do, people
<haelix>
So you decided you'd come along here and hyp your newly acquired fluency in Ocaml ?
jynxzero has quit ["leaving"]
<mellum>
haelix: yes :)
<haelix>
welcome to level 2, then !!(beware: this level's monster function is a 500 hundred line one)
<haakonn>
plus it has optional arguments and a web of reference assignments
<haelix>
yeah. And it calls C functions under the cover
<haakonn>
and the C functions leak memory
<haelix>
Can't we keep that for level 3 ?
<haakonn>
right, right :)
<mellum>
Is there a constant that determines the compiler version?
<smimou>
Sys.ocaml_version
<mellum>
Ah, thanks.
Snark has joined #ocaml
gim has joined #ocaml
vodka-goo has joined #ocaml
<haakonn>
why are so many of the stdlib data structures mutable, you'd think the masterminds of a functional language knew better
Snark has quit ["Leaving"]
Submarine has quit ["Leaving"]
<vodka-goo>
haakonn: they wanted them efficient
<vodka-goo>
but you have purely functionnal equivalents for the most common ones
<haakonn>
how about Queue?
<haakonn>
never mind, i have to write my own anyway :)
__DL__ has joined #ocaml
Submarine has joined #ocaml
Submarine has quit ["in Soviet Russia, Céline Dion owns you"]
ski_ has joined #ocaml
ski has quit [Nick collision from services.]
ski_ is now known as ski
<vodka-goo>
I'd code a Queue by the pop function, the add function being add f x = fun () -> match f () with None -> Some (x,(fun x -> None)) | Some (y,newf) -> Some (y,add newf x).
<mellum>
sounds horribly inefficient.
<ski>
indeed
m3ga has quit ["disappearing into the sunset"]
<vodka-goo>
that's why the stdlib is not purely functionnal, as I said before :)
<mellum>
well, you can make a functional queue that is much more efficient that this...
<vodka-goo>
what's your proposition ?
ski_ has joined #ocaml
ski has quit [Nick collision from services.]
ski_ is now known as ski
Submarine has joined #ocaml
threeve has joined #ocaml
<rossberg>
vodka-goo: take this:
<rossberg>
type 'a queue = 'a list * 'a list
<rossberg>
let push (front, back) x = (front, x::back)
<rossberg>
let rec pop = function | ([], []) -> raise (Failure "pop") | ([], back) -> pop (List.rev back, []) | (x::front, back) -> (x, (front, back))
<rossberg>
amortized constant time for both push & pop
Skal has quit [Remote closed the connection]
<vodka-goo>
nicer, indeed
<vodka-goo>
I didn't think to the amortization thing
Smerdyakov has quit []
Smerdyakov has joined #ocaml
Snark has joined #ocaml
Skal has joined #ocaml
ski has quit ["NMI"]
ski has joined #ocaml
ski_ has joined #ocaml
ski has quit [Nick collision from services.]
ski_ is now known as ski
vezenchio has quit [""The law, in its majestic equality, forbids the rich as well as the poor to sleep under bridges, to beg in the streets, and t]
ski_ has joined #ocaml
ski has quit [Nick collision from services.]
ski_ is now known as ski
ski has quit [Connection timed out]
Submarine has quit ["in Soviet Russia, Céline Dion owns you"]