dylan changed the topic of #ocaml to: OCaml 3.09.1 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
<zmdkrbou> it would be 4 :: 5 :: list
<Thlayli> k, thanks
<zmdkrbou> ( read 4::(5::list) )
<Thlayli> next time i'll remember ;)
<pango> :: type is 'a -> 'a list -> 'a list
<Thlayli> so why don't i get any ouput if i just write: start::mylist; print_list mylist;
<Thlayli> it works perfectly with let nat = start::mylist;
<Thlayli> print_list nat;
<pango> start :: mylist doesn't modify mylist
<Thlayli> so it returns a new list?
<pango> is returns a new list, that is immediately discarded (unless you omitted to mention some code)
<Thlayli> k, thanks
<pango> s/is/it/
<Thlayli> yeah, we sure all like sed :D
<pango> or ed, or perl,...
<Thlayli> finally, could you please gimme a site with good small exercises to become familiar with the camel
<Thlayli> never programmed in perl :(
<Thlayli> i only found a french site
<Thlayli> just code, no real exercises there
<Thlayli> and i'm not ready to code some difficult algorithms by now
<pango> not sure about exercises
<Thlayli> already got the sieve of erastosthenes
<Thlayli> some things like this
<Thlayli> tried some things with lists and so on. some small utility functions like print_list etc.
<Thlayli> hmm, hmm...
<Thlayli> i'll try binarysearch
<Thlayli> thx
<Thlayli> i'll go to bed in half an hour
<Thlayli> have a nice day/night/whatever
<Thlayli> bye
Thlayli has quit ["Lost terminal"]
descender has quit [Remote closed the connection]
shawn has quit [Connection timed out]
shawn has joined #ocaml
<Myrizio> whoha!!! gcaml rulez :)
<Myrizio> pango, ketty: gcaml allows me to define the "wrap" function!! :)
<Myrizio> let rec wrap = generic
<Myrizio> | : ('a->'b)->'a->'b => fun func v -> wrap (func v)
<Myrizio> | fun arg -> hello (); arg
<Myrizio> ;;
* Myrizio is happy
Smerdyakov has joined #ocaml
khaladan has quit [Read error: 104 (Connection reset by peer)]
mikeX has quit ["zzz"]
<ketty> Myrizio: nice :)
<Myrizio> :)
Revision17 has quit ["Ex-Chat"]
dark_light has quit [No route to host]
khaladan has joined #ocaml
Revision17 has joined #ocaml
shawn has quit ["This computer has gone to sleep"]
shawn has joined #ocaml
Myrizio has quit ["Leaving"]
jcreigh has joined #ocaml
DannoHung has joined #ocaml
<DannoHung> Hi. I was wondering if there's a sleep command? There isn't anything mentioned on ocaml-tutorial.org
<Smerdyakov> There are no commands in OCaml.
<DannoHung> Sorry, function
<Smerdyakov> Maybe you mean such a _function_ in the standard library?
<ketty> mm.. in the Unix module there is a function...
<DannoHung> Is it just Unix.sleep ?
<Smerdyakov> DannoHung, do you know where the manual is?
<ketty> i think so :)
<DannoHung> Smerdyakov: Nope. Very new to OCaml. It's for a class. We're writing a dining philosophers problem in Jocaml and the output is whizzing by too fast for me to figure out what's happening.
<DannoHung> Thanks
<DannoHung> This type inferencing thing is pretty cool. It makes static typing... bearable.
<Smerdyakov> Dude, just wait. You will come to see how static typing changes hacking into software engineering. :)
<DannoHung> Shouldn't there be a qualifier on that? Because traditional static typing made me question whether I wanted to maybe get into lawn care...
<Smerdyakov> Yes. You will come to see how a particular approach based around static typing has that property. :)
<DannoHung> Hrmmm... damned hippy philosophers... taking other people's cutlery...
jcreigh has quit ["leaving"]
Quinthius has quit ["Leaving"]
<DannoHung> Curses... system specific errors... Guess I need to see a TA or something. Thanks for the help!
DannoHung has quit []
joshcryer has joined #ocaml
Quinthius has joined #ocaml
Smerdyakov has quit ["Leaving"]
pango is now known as pangoafk
pangoafk is now known as pango
revision17__ has joined #ocaml
Revision17 has quit [Read error: 110 (Connection timed out)]
vinceviper has quit ["Leaving"]
Myrizio has joined #ocaml
<Myrizio> can i have parameterised variants with more than one parameter?
Skal has joined #ocaml
yangsx has joined #ocaml
Myrizio has quit ["Leaving"]
Skal has quit [Remote closed the connection]
yangsx has left #ocaml []
<flux__> hmm, more than one parameter is the same as one parameter that is a tuple?
mikeX has joined #ocaml
Myrizio has joined #ocaml
Schmurtz has joined #ocaml
metaperl has joined #ocaml
ulfdoz has quit [herbert.freenode.net irc.freenode.net]
ulfdoz has joined #ocaml
ulfdoz has quit [herbert.freenode.net irc.freenode.net]
ulfdoz has joined #ocaml
mikeX_ has joined #ocaml
mikeX has quit [Nick collision from services.]
mikeX_ is now known as mikeX
Thlayli has joined #ocaml
JKnecht has joined #ocaml
ski has quit [Read error: 110 (Connection timed out)]
ski has joined #ocaml
<Thlayli> hi again. i managed to get quite far with OCaml since yesterday, but there's still one thing i'm not sure about:
<Thlayli> sometimes "match" is substituted by function [] | ...
<Thlayli> is this exaclty the same or is there a difference?
<Thlayli> e.g let func x y = match x with ...
<flux__> well, 'function' doesn't fit that case
<Thlayli> ket func x y = function [] ->
<flux__> but let func x = match x with _ -> .. is exactly the same as let func = function _ -> ..
<Thlayli> ah
<Thlayli> so i can use the function keyword instead of creating a match statement?
<Thlayli> like function x -> ... | function y ->
<Thlayli> or am i wrong?
<mikeX> I don't think so
<flux__> function creates a function that has one anonymous parameter, and a match over it
<flux__> so function is not a replacement for match, but for fun x -> match x
<flux__> (+with)
<Thlayli> ah, thanks
<Thlayli> so what's the difference between let myfunc = fun x -> ...
<Thlayli> and simply let myfunc = ...
<Thlayli> i meant let myfunc y = fun x -> ...
<Thlayli> and simpley let myfunc y =
<mikeX> Thlayli: your statements are 2 different things
<mikeX> in the first case, you have myfunc which takes 2 arguments, y and x
<mikeX> in the second, only one, y
<mikeX> you should experiment with the toplevel to get a better feel of it
<Thlayli> i see. you know, my script is kinda odd. they use for example the same names for different arguments
<Thlayli> but very thanks for information
<mikeX> # let myf y = fun x -> print_int x ;;
<mikeX> val myf : 'a -> int -> unit = <fun>
<mikeX> # let myf = fun x -> print_int x ;;
<mikeX> val myf : int -> unit = <fun>
<mikeX> note that the 'function' keyword is different than 'fun'
<mikeX> you have to understand that functions are first class citizens, meaning you can assign functions to variables
<mikeX> that's the whole point of 'let myfunc = function ...'
<mikeX> the 'let myfunc x = ...' is syntactic sugar, if I'm not mistaken
<mikeX> so is the 'fun' keyword
<Thlayli> ah
<Thlayli> ok, i think i don't need it by now
Quinthius has quit ["Leaving"]
mikeX_ has joined #ocaml
mikeX has quit [Nick collision from services.]
mikeX_ is now known as mikeX
Smerdyakov has joined #ocaml
Schmurtz has quit [Read error: 104 (Connection reset by peer)]
Schmurtz has joined #ocaml
khaladan has quit [Read error: 104 (Connection reset by peer)]
ski_ has joined #ocaml
ski has quit [Nick collision from services.]
ski_ is now known as ski
Snark has joined #ocaml
Schmurtz has quit [Read error: 104 (Connection reset by peer)]
Schmurtz has joined #ocaml
<Thlayli> let rec all_nats n = n :: all_nats (n+1);;
<Thlayli> thie function creates an infintite list of nats
<Thlayli> i'm just cirious: :: is the list constructor
<Thlayli> i saw it only in the form elem::elem2::[]
<Thlayli> so if the [] at then end is missing
<Thlayli> will i ever get a list?
<ketty> its form is: elem::[]
<ketty> so elem::elem2::[] is elem::(elem2::[])
<Thlayli> yeah, so if the [] at then end is missing, like in "let rec all_nats"
<ketty> its not the end that is missing
<Thlayli> i won't get a list type returned
<Thlayli> is that so?
<ketty> :: allways returns a list
<ketty> its type is 'a -> 'a list -> 'a list
<Thlayli> i tried in the interpreter: "1::2::3::4::5"
<flux__> that function will however never return
<Thlayli> and get this error message This expression has type int but is here used with type int list
<flux__> 1::2::3::4::5::[] would be the proper form
<Thlayli> i know it will never return
<flux__> or 1::2::3::4::[5]
<Thlayli> yeah, that's why i think the function isn't valid
<flux__> or [1; 2; 3; 4; 5] ;)
<Thlayli> if infinity could end
<Thlayli> i would get no list returned
<Thlayli> but rather an error message
<Thlayli> in all_nats
<flux__> you have a problem with that function definition?
<Thlayli> i'm just curious
<ketty> # let rec all_nats n = n :: all_nats (n+1);;
<ketty> val all_nats : int -> int list = <fun>
<Thlayli> if i would use that function to craete a non-infinte list
<ketty> isn't this what you want?
<Thlayli> hmm, i think you don't understand me (no wonder ;) )
<Thlayli> it's a stupid question anyway. it never terminates and therefor my question is garbage
<Thlayli> but if it would terminate, i would get an error with this syntax
<ketty> why do you think that?
<Thlayli> because the ::[] is missing at the end
<ketty> its not :)
<ski> let rec down_from n = n :: (if n = 0 then [] else down_from (n-1));;
<ski> try that
<flux__> let rec funny_list = 42 :: 44 :: funny_list
<flux__> this doesn't have [] in the end either ;)
<Thlayli> and it's infinite as well
<ketty> ":: []" is not necesary.. it does nothing.
<flux__> but, you might be aware of the stream-feature (provided by camlp4o), which would let you write let all_nats n = [<'n; all_nats (n + 1)>]
<ketty> 1 :: [2] and 1 :: 2 :: [] are both the same
<Thlayli> i know
<Thlayli> i got it now
<ketty> and the type of "all_nats (n+1)" is not an element, but a list..
<Thlayli> yes
<Thlayli> i didn't quite understand this at first hand
<Thlayli> i thought i'm adding element to element to element and so on
<Thlayli> but i add an element to a list, and to this list another element...
<Thlayli> thanks for your help
Morphous has joined #ocaml
Amorphous has quit [Read error: 110 (Connection timed out)]
smimou has joined #ocaml
ski has quit [Read error: 110 (Connection timed out)]
Morphous is now known as Amorphous
pango is now known as pangoafk
Myrizio has quit [Read error: 110 (Connection timed out)]
Myrizio_ has joined #ocaml
pangoafk is now known as pango
<pango> Thlayli: they're valid programs that shouldn't return (operating systems ?)
_JusSx_ has joined #ocaml
<_JusSx_> HI OCAML PPL
<pango> hi, caps man ;)
<pango> Thlayli: it program termination always conflicted with correct typing, you'd be famous by now ;)
rillig has joined #ocaml
mikeX has quit [Read error: 104 (Connection reset by peer)]
mikeX has joined #ocaml
_fab has joined #ocaml
Schmurtz has quit ["Dodo !"]
khaladan has joined #ocaml
smimou has quit [Read error: 110 (Connection timed out)]
mauke_ has joined #ocaml
<Thlayli> let graph = [| (0, 1, 5); (0, 4, 10); (1, 3, 3); (1, 4, 7); (2, 3, 3); (3, 4, 3)
<Thlayli> |];;
<Thlayli> what's wrong with this?
<Thlayli> gives me a syntax error near ;;
<Thlayli> trying to implement dijkstra :(
<ketty> works for me...
<ketty> i get: val graph : (int * int * int) array =
<ketty> [|(0, 1, 5); (0, 4, 10); (1, 3, 3); (1, 4, 7); (2, 3, 3); (3, 4, 3)|]
<Thlayli> syntax error near unexpected token `;;'
<ketty> i get no syntax error...
<Thlayli> hmm, i'm currently using the ocaml interpreter
<ketty> i pasted what you wrote...
<ketty> me too...
<Thlayli> yes, i pasted what's in my file
<ketty> hmmm.. weird :)
<Thlayli> well i use ocamlrun ocaml
<ketty> ahh..
<ketty> not me
<ketty> i use the toplevel
<Thlayli> i'll try that
<ketty> is there more things in your file?
<ketty> the problem could be somewhere else...
<ketty> is the definition of graph nested inside anything else?
<Thlayli> nope
<Thlayli> it's what one would call global
<Thlayli> don't know if that term applies to Ocaml
<Thlayli> however, toplevel works fine
<Thlayli> does not complain
rillig has quit ["exit(EXIT_SUCCESS)"]
<ketty> ocaml test.ml - this works for me
<ketty> with test.ml containing your line...
<Thlayli> yes, works for me also
<Thlayli> but this code does obviously not like to be treated like a shell script :)
<ketty> mm?
<Thlayli> well, i write my testprograms like shell-scripts with the ocamlrun interpreter
<ketty> should not matter...
<Thlayli> with #!/usr/local/bin/ocamlrun ocaml as shebang
<Thlayli> worked perfectly until now
<ketty> works as a script for me...
<Thlayli> strange
<ketty> have you tried the exact same file with ocaml ?
<ketty> ie not as script
<Thlayli> The Objective Caml runtime, version 3.09.0
<Thlayli> yes
<ketty> and it works then?
<Thlayli> i removed the shebang and passed to the toplevel
<Thlayli> worked
<ketty> but not as script... strange..
<ketty> my caml version is: 3.09.1 by the way..
<ketty> maybe there is some strange bug in yours... :/
<Thlayli> probarbly
<Thlayli> i messed a bit with my system, though
mauke has quit [Read error: 110 (Connection timed out)]
<Thlayli> since my did not want to compile the last update
<Thlayli> i manually edited some header files ^^
<ketty> you could try to use godi..
<Thlayli> godi?
<Thlayli> what's that?
<ketty> its a source distribution of ocaml and libs...
<Thlayli> thanks
<Thlayli> i'll give it a try :)
<Thlayli> i like OCaml more and more while learning it
<ketty> and you can install it without messing with your system.. :)
<Thlayli> ketty are you german?
<ketty> no
<ketty> swedish...
<Thlayli> ah
<Thlayli> was just curious because of the de-website
<Thlayli> since i am german
<ketty> ok..
<Thlayli> and my english is far away from being perfect ^^
<ketty> as is mine...
<ketty> i want to learn to many languages to have time to learn any of them well :)
<Thlayli> i haven't learned any since school. i only speak german and french
<ketty> currently i want to learn japanese, chinese and russian.. :)
<Thlayli> a friend of mine visited stockholm last year and told me some swedish words, but i already forgot them. no wonder if you don't get a chance to use them. and now i met someone from sweden and can't even say hello in his language :(
<ketty> "hej"
<Thlayli> i'll try my best to remember ;)
stockholm has joined #ocaml
<stockholm> Hello, I'm wondering if there is someone who has a couple of minutes to spare to talk in-depth about optimizing OCaml code with me? Specifically, I'm working on a library for computer vision, and am attempting to make it as fast as a similar implementation in C++, but am coming up 3x-4x slow. Thanks in advance for you time.
Snark has quit [Read error: 110 (Connection timed out)]
mauke_ is now known as mauke
Demitar has joined #ocaml
<ketty> stockholm: sorry, i no nothing about optimization.. you might want to post to the mailing list also..
<stockholm> ketty: Yea, that's a good idea. I've been reading through all of the old mailing list posts for the past years, and have gotten lots of good tips from them.
slipstream has quit [Read error: 104 (Connection reset by peer)]
slipstream has joined #ocaml
<Thlayli> is there a way to access list elements by index?
<_JusSx_> Thlayli: no
<Thlayli> thx
_JusSx_ has quit ["leaving"]
<ketty> Thlayli: List.nth
<Thlayli> thx ketty
<Thlayli> so there is a way
<mikeX> Thlayli: keep in mind that you have to iterate over N elements to access the Nth element of a list
<Thlayli> thanks for the info, but i am not aiming for performance at the moment.
<ketty> if you would want fast random access you should use arrays..
<Thlayli> yes, but this is neglibigle for the small set that i have
<Thlayli> i would not want to implement a resizable array for it
<ketty> you dont need to implement it..
<Thlayli> really?
<Thlayli> is there a datatype like vector?
<ketty> there is arrays in the standard library...
<Thlayli> hmm, is there a good reference for the standard-library i can dig into?
<ketty> have you looked at the manual?
<Thlayli> yes
<Thlayli> and it was kinda odd
<dylan> it's in the manual.
<stockholm> Go to ocaml.org, and click on "Resources", there's excellent documentation on the standard library there.
<Thlayli> whenever i clicked on a link that was beyond section 1.6 or so it did not work
<Thlayli> i was taken to the bottom of the page ^^
<Thlayli> dunno
<ketty> hmm?
<Thlayli> that was on the inria website
<stockholm> Yea. ocaml.org is the same thing.
<Thlayli> what the deuce? i dunno what me stupid moron did wrong before
<Thlayli> but now it works
<ketty> great :)
marc has joined #ocaml
<marc> hello.
<ketty> hello
<Thlayli> so, i'm finished for today
_fab has quit []
<marc> I have a problem when i compile http://rafb.net/paste/results/U0Awl270.html with ocamlc. I get a segfault at execution. Can someone try to compile and execute it on its computer ?
<ketty> with ocaml and ocamlc i get segfault, but not with ocamlopt
<marc> It's probably a bug in ocamlc but i did not succeed to isolate it.
<marc> yep.
<Thlayli> segfault here, too
<marc> ocamlc -v
<marc> The Objective Caml compiler, version 3.09.1
<ketty> mine to
<ketty> you should probably submit a bug report
<Myrizio_> mh, i get segfault with ocaml interpreter too...
smimou has joined #ocaml
<Myrizio_> maybe some stack overflow?
<ketty> that would generate a stack overflow exception (or error?)
<marc> It may be a bug in ocamlrun.
<ketty> generaly if you get segfault and you are not using "unsafe" features it is a bug in the ocaml system...
<marc> Ok, i will try to submit a report.
<Myrizio_> ketty: i did not know this fact :)
<marc> i should try to compile it on the latest ocaml version.
<ketty> yes, and you might want to try cvs too...
stockholm has quit []
<Myrizio_> BTW, gcaml has the bug (and gcaml is based on ocaml 3.09.0), so this bug is not specific of 3.09.1
<marc> I will mail the caml list and let gurus handling this bug.
<marc> is there theoretic difficulties for type inference in the module system ?
<marc> don't metacoders waste too much time writing signatures ?
<Demitar> marc: Two curious facts which might be helpful: 1) Without the call to LS.add it doesn't segfault. 2) Adding one explicit parameter to LL.add (let add x = ... x) makes it work properly as well. (Of course, since I didn't force maximum garbage collection it could be a timing issue.)
vitriol_ has joined #ocaml
<vitriol_> what is the difference between defining type foo = A | B | C and type foo = [ `A | `B | `C ] ?
<Demitar> vitriol_: The latter are polymorphic variants.
<marc> I have already notice that.
<marc> I have send a mail to the caml list with this remark.
<Demitar> marc, *nods*
<marc> i haven't understand «Of course, since I didn't force maximum garbage collection it could be a timing issue
<marc> »
khaladan has quit [Read error: 110 (Connection timed out)]
<Demitar> marc: I recall from some message on the mailing lists that you can force the garbage collector to collect all heaps every cycle and thus catch memory management issues much closer to their actual breakage.
vitriol_ has quit [Remote closed the connection]
smimou has quit ["bli"]
<pango> Thlayli: ocamlrun is *bytecode* interpreter, to write "interpreted scripts" you must use #!/usr/bin/ocaml not #!/usr/bin/ocamlrun
<pango> marc: works for me with ocamlc 3.08.3 (Debian)
<marc> there is a change about recursive modules.
<marc> they may have add a bug.
<marc> (i have been disconnected ?)
<marc> there is a change about recursive modules.
<marc> they may have add a bug.
khaladan has joined #ocaml