cjeris changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
pedro__ has joined #ocaml
mikeX has quit ["leaving"]
pedro_ has quit [Read error: 110 (Connection timed out)]
bzzbzz has joined #ocaml
<seoushi> I've tried eprintf, printf and print_string and they only print out after I exit my program. Is there some trick to making them print out as soon as they are called?
<malc_> flush std[out|err] Printf %! Format %@
<seoushi> thanks
malc_ has quit ["leaving"]
bebui has quit [Read error: 110 (Connection timed out)]
malc_ has joined #ocaml
ramky has quit [Read error: 104 (Connection reset by peer)]
ramky has joined #ocaml
malc_ has quit ["leaving"]
screwt8 has quit [Remote closed the connection]
screwt8 has joined #ocaml
Mr_Awesome has joined #ocaml
Smerdyakov has quit ["Leaving"]
cheese` has joined #ocaml
<cheese`> Hi, I need some ocaml help if anyone is willing!
<levi_home> I'm rusty, but I'll help if I can.
<cheese`> I have two functions that need to call each other
<cheese`> but first can't call second
<cheese`> because second is not defined
<levi_home> Ahh.
<cheese`> just don't know how to get around this
<levi_home> You can simultaneously define them, so they'll be able to call each other.
<cheese`> how
* levi_home tries to remember the way to do that.
<levi_home> I believe let ... and let ... ;; will do it
<cheese`> syntax error beginning at second function definition
<levi_home> Sorry, there's no second let, it's just let ... and ... ;;
<cheese`> yeah that worked thanks!
<cheese`> also need to make it rec
<cheese`> or it doesn't recognize first
<Mr_Awesome> those pesky mutually recursive functions
<cheese`> gotta love the projects that require stuff not taught in class so I have to jump on random irc channels to get the answers!
araujo has quit ["Leaving"]
m3ga has joined #ocaml
m3ga has quit [Client Quit]
benny has joined #ocaml
benny_ has quit [Read error: 60 (Operation timed out)]
kig has joined #ocaml
kig_ has joined #ocaml
Gone_ has joined #ocaml
kig_ has left #ocaml []
Gone has quit [Read error: 110 (Connection timed out)]
bebui has joined #ocaml
ikaros has quit ["segfault"]
kig has quit [Read error: 110 (Connection timed out)]
Submarine has quit ["Leaving"]
Mr_Awesome has quit ["...and the Awesome level drops"]
_JusSx_ has joined #ocaml
bluestorm_ has joined #ocaml
ikaros has joined #ocaml
bluestorm_ has quit ["Konversation terminated!"]
bluestorm_ has joined #ocaml
Gone_ is now known as G
kig has joined #ocaml
bluestorm_ has quit ["Konversation terminated!"]
m3ga has joined #ocaml
TaXules has joined #ocaml
m3ga has quit ["disappearing into the sunset"]
benny99 has joined #ocaml
benny99 has left #ocaml []
pedro__ has quit ["Abandonando"]
Smerdyakov has joined #ocaml
benny99 has joined #ocaml
<benny99> hi
<benny99> somebody knows an (even?) more elegant way to this? http://rafb.net/p/Z6hQnO24.html
<benny99> just 5 lines, unbelievable how powerful ocaml is :o
Submarine has joined #ocaml
<mattam> You can get rid of the tupling of first and second, ocaml supports simultaneous pattern matching on multiple values
<benny99> so how must I write it then ?
<benny99> match first, second with ?
<mattam> exactly
<benny99> thank you :)
ikaros has quit ["segfault"]
<benny99> http://rafb.net/p/YxhIaR43.html what's wrong :( ?
<benny99> I get a syntax error in line 6
<benny99> the ;;
<Smerdyakov> Look at the code again and ask yourself that question.
<Smerdyakov> The error has nothing to do with what you asked about.
<benny99> got it
<benny99> Smerdyakov: aeeh, I asked about what is wrong :p
<benny99> Smerdyakov: if it had nothing to do with it, it would be correct ^^
<Smerdyakov> No.
<benny99> but I got it
<Smerdyakov> I mean your question before that.
<pango> mmh btw is the function supposed to merge two sorted lists into one ?
<pango> # merge_i [0;1;3] [2] ;;
<pango> - : int list = [0; 2; 1; 3]
<mrvn> 'let rest = merge_spec first second' make no sense
<benny99> ah, lol
<benny99> mrvn: thanks ...
<pango> (ooups! :) )
<benny99> pango: it is
<benny99> pango: but the two lists should be sorted, too
<mrvn> and s/;;/in merge_spec first second
<mrvn> ;;
<benny99> pango: uh, it does not work :| ?
<mrvn> Ad remove the first rec
<benny99> mrvn: ??
<mrvn> val merge : 'a list -> 'a list -> ('a -> 'a -> bool) -> 'a list = <fun>
<benny99> mrvn: thanks
<mrvn> let merge first second comp =
<mrvn> let rec merge_spec first second = match first, second with
<mrvn> f, [] -> f
<mrvn> | [], s -> s
<mrvn> | fh::ft, sh::st -> let rest = merge_spec ft st in
<mrvn> if (comp fh sh) then fh::sh::rest else sh::fh::rest in
<mrvn> merge_spec first second;;
<benny99> mrvn: yeah, that's what I got now ;)
<benny99> mrvn: hm, amazing - I guess the code is much longer in C++ for example :p ?
<benny99> hm, if it's not in increasing order it doesn't work -- it gets more interesting now :p
<mrvn> benny99: obviously the two input lists must both be sorted already.
<benny99> mrvn: yeah, of course
<mrvn> And you can't do fh::sh::rest. the next item in fs might be smaller than sh.
<benny99> mrvn: What I meant was: OK, that is done, I'll go and write another function that does more
<mrvn> And in my paste I added tail recursion as well.
<benny99> mrvn: thanks for your paste -- but I won't look at it for now (store it for later) since I want to learn ocaml
<mrvn> benny99: Look at Pervasives.compare
<mrvn> 'a -> 'a -> bool is a poor compare function.
<benny99> mrvn: thank you :)
<benny99> mrvn: but I must leave you now :(
<benny99> mrvn: hm, so thanks once again and bye :)
benny99 has left #ocaml []
mqtt has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
<ulfdoz> This is the pattern I try to match 'If (tst, (Block cmds) as blk, opt_else, tp)', this is the error I get: "The constructor If expects 4 argument(s),
<ulfdoz> but is here applied to 3 argument(s)"
<ulfdoz> ideas?
<flux> ulfdoz, as and comma precedency
<flux> ,binds tighter
<mrvn> But that would make it 2 arguments
<Smerdyakov> The OCaml tuple parsing rules are just ridiculous.
<Smerdyakov> Sure, you save some typing sometimes, but you can get seriously demented misparses.
<flux> ((tst, (Block cmds)) as blk, opt_else, tp)
<flux> looks like three to me
<mrvn> ahh, I was thinking the other way around, tst, (Block cmds)) as (blk, opt_else, tp))
<ulfdoz> flux: thx.
<flux> I don't think that's even possible?
mqtt_ has joined #ocaml
<mrvn> syntactically sure, type wise it is an error
<Smerdyakov> mrvn, 'as' isn't symmetric. The righthand argument is a variable.
<mrvn> or maybe not. :(
mqtt has quit [Read error: 110 (Connection timed out)]
<ulfdoz> argh, missing ad-hoc polymorphism.
<mrvn> Like 'Foo bar?
<ulfdoz> No, like do_nothing = id
<mrvn> ulfdoz: ignore :)
<mrvn> # let do_nothing (a:'a) = a;;
<mrvn> val do_nothing : 'a -> 'a = <fun>
<mrvn> # do_nothing 1;;
<mrvn> - : int = 1
<mrvn> # do_nothing "a";;
<mrvn> - : string = "a"
<mrvn> Like that?
<ulfdoz> Hm, looks good.
<pango> ain't that just polymorphism ?
<mrvn> yep
<mrvn> if at all
<ulfdoz> Ehm, no it isn't. And it isn't needed if I'm right. The type-checker can unify the type-variable to a specific type from context of function call.
<pango> static polymorphism then ? :)
<mrvn> The ocaml manual has some example where you need to specify the type to stop the type checker from infering the type too much.
<pango> from what I understand, specifying a type doesn't change the type inference pass, just add more restrictions later
bluestorm_ has joined #ocaml
<flux> let do_something (a:'a) = a + 42 works too
<flux> only module signatures actually limit the type
<flux> well, i suppose something like (a: ('a * 'a)) would be counting as limiting the type..
<Smerdyakov> pango, question marks never have spaces before them in English.
<pango> Smerdyakov: I guess nobody cared
|Lupin| has joined #ocaml
<|Lupin|> Hi, Camlers
<|Lupin|> I'm having a compilation problem
<|Lupin|> trying to build a library with a command like this:
<|Lupin|> ocamlfind ocamlopt -a -o lib.cmxa -package unix -linkpkg fils...
<|Lupin|> this gives the following error
<|Lupin|> /usr/lib/ocaml/3.09.2/unix.cmxa is not a compilation unit description.
<|Lupin|> Any idea ?
<flux> corrupted installation?
<flux> just guessing
<|Lupin|> I don't think so...
<flux> does it work normally, while producing executables?
<|Lupin|> It's a nice Debin...
<|Lupin|> Yes.
<|Lupin|> I also tried without the package options and with an explicit ref to bhe unix.cmxa file
<|Lupin|> and also with unix.cmx
<|Lupin|> nothing worked
<flux> well, maybe you're doing it wrong :). have you tried compiling other findlib-based libraries?
<|Lupin|> No...
<|Lupin|> But Icopied quas-verbatim the example from the findlib manual...
<flux> well, I'd try to do that first. can't recall a native ocaml-lib, though, but there are tons of oc.aml libraries in debian, you should be able to find one in no time :)
<|Lupin|> okay flux
<|Lupin|> thanks a lot for your advice
<|Lupin|> I'll give that a try and see...
<|Lupin|> dinner time, bye !
|Lupin| has left #ocaml []
_JusSx_ has quit [Read error: 110 (Connection timed out)]
Smerdyakov has quit ["Leaving"]
benny99 has joined #ocaml
<benny99> hello channel
benny99 has left #ocaml []
bebui_ has joined #ocaml
bebui_ has quit [Client Quit]
descender has joined #ocaml
swater has joined #ocaml
bwerf has joined #ocaml
<bwerf> does ocaml have currying ?
shachaf has joined #ocaml
shachaf has left #ocaml []
<pango> bwerf: sure
<pango> # let f a b = 3 * a - b ;;
<pango> val f : int -> int -> int = <fun>
<pango> # f 7 ;;
<pango> - : int -> int = <fun>
<pango> (f 7) 2 ;;
<pango> - : int = 19
<bwerf> ah great
<bwerf> been looking at haskell, but pure functional is still a bit scary
<mrvn> bwerf: ocaml has autocurrying
<mrvn> i.e. let f a b as oposed to let f = function a -> function b ->
malc_ has joined #ocaml
kig has quit [Remote closed the connection]
kig has joined #ocaml
swater has quit ["Quat"]
slipstream-- has quit [Read error: 54 (Connection reset by peer)]
slipstream has joined #ocaml
kig has quit [Remote closed the connection]
kig has joined #ocaml
benny99 has joined #ocaml
kig has quit [Remote closed the connection]
kig has joined #ocaml
benny99 has quit [zelazny.freenode.net irc.freenode.net]
bluestorm_ has quit [zelazny.freenode.net irc.freenode.net]
Submarine has quit [zelazny.freenode.net irc.freenode.net]
TaXules has quit [zelazny.freenode.net irc.freenode.net]
a-priori_ has quit [zelazny.freenode.net irc.freenode.net]
lucca has quit [zelazny.freenode.net irc.freenode.net]
z_ has quit [zelazny.freenode.net irc.freenode.net]
benny99 has joined #ocaml
bluestorm_ has joined #ocaml
Submarine has joined #ocaml
TaXules has joined #ocaml
a-priori_ has joined #ocaml
z_ has joined #ocaml
lucca has joined #ocaml
a-priori_ has quit [Remote closed the connection]
a-priori_ has joined #ocaml
<benny99> lol :o
<benny99> hmk, I'll read that article
<benny99> I thought the world would be destroyed :(
<benny99> if I'd be Bush now, I'd kill a country
bwerf has left #ocaml []
kig__ has joined #ocaml
kig has quit [Read error: 104 (Connection reset by peer)]
Smerdyakov has joined #ocaml
kig has joined #ocaml
kig__ has quit [Read error: 110 (Connection timed out)]
danly has quit [Remote closed the connection]
Mr_Awesome has joined #ocaml
<benny99> gone : )
benny99 has left #ocaml []
postalchris has joined #ocaml
bluestorm_ has quit ["Konversation terminated!"]