flux__ changed the topic of #ocaml to: OCaml 3.09.2 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/
Purice has joined #ocaml
<dylan> zedrdave: 2D arrays, 3D arrays, or what?
<zedrdave> dylan: hmn. at least 3D arrays...
_fab has quit []
<zedrdave> basically: I have a funct that returns an array of custom type elemts. and I'd like an M by N matrix of these...
<zedrdave> I mean, I made it finally work using mapi and an aux function...
<dylan> So, perhaps you want a function like this: (int * int * int -> 'a) -> int -> 'a array array array
<zedrdave> but it sounds incredibly tedious as a standard way to do it..
<zedrdave> dylan: hmn. I'm not really following you here...
<dylan> let's give it a name:
<dylan> let make_my_array f size = ...
<zedrdave> ok?
<dylan> where f is a function taking a 3-tuple (the coordinates of the array) and returning the element that should go there.
<zedrdave> ok so far...
<zedrdave> now what would I have in the body of make_my_array?
<dylan> I dunno. There are a lot of ways to do it.
<zedrdave> hmn... well, this is the specific bit I'm having trouble with..
<zedrdave> which way would you pick out of these many ways?
<zedrdave> because I don't even have one good way...
<dylan> the most functional-style one.
<zedrdave> that is?
* dylan decides to sketch out the function, as it is more interesting than his day job.
* zedrdave is dying to see the result..
<zedrdave> basically, I'd want something that does exactly the same as .create or .create_matrix, but just with physically different elems. so that when I use "<-" I don't just overwrite the same elem, again and again..
<dylan> One of the functions you need is Array.init
<dylan> # Array.init 3 (fun i -> String.make 10 'x');;
<dylan> - : string array = [|"xxxxxxxxxx"; "xxxxxxxxxx"; "xxxxxxxxxx"|]
<zedrdave> hmn... yea, that's what I use...
<zedrdave> but because I need nested, it makes it quite tedious...
<zedrdave> oh well, I guess a lot of nested (fun f ->) with init might work..
<zedrdave> thanks for the help
<dylan> Almost got it to type check...
<zedrdave> hmn yea... typing is what I had problem with earlier on
CosmicRay has quit ["Client exiting"]
<zedrdave> thanks, I'll try it on my code as soon as I'm done with the rest...
<dylan> not bad for five lines.
<dylan> I have a feeling it could be made more generic...
<zedrdave> indeed. I'm not 100% sure it will work with my custom type...
<zedrdave> that I'm stocking in arrays...
<zedrdave> but i'll try later and tell you...
<zedrdave> can't do much more on the script as it's now running and crunching numbers happily already.
<dylan> it should work for any type...
<dylan> any 3d array, anyway
<zedrdave> ok. just I had some weird complaint about it not getting its required type before... (something like "want int -> (int -> 'a), got int -> (int -> yourtype)"
<zedrdave> well, only 30 mins left to go before the script runs through...
<zedrdave> (joys of X[100000] polynomials)
Purice has quit ["Leaving"]
mikeX has quit ["zzz"]
khaladan has quit [Read error: 104 (Connection reset by peer)]
dbueno has joined #ocaml
<dbueno> In an ocamllex rule, is there a way to match the beginning of a line?
zedrdave has quit []
<Smerdyakov> Isn't the beginning of a line just a newline character?
<dylan> Not if it's already consumed, which I imagine what dbueno means.
khaladan has joined #ocaml
chessguy has joined #ocaml
jcreigh has joined #ocaml
pirata has joined #ocaml
jcreigh has quit ["Do androids dream of electric sheep?"]
<fluxx> dbueno, I've just used: start with a parser that assumes BOL, when encountering '\n' continue with the same parser
Smerdyakov has quit ["Leaving"]
ramkrsna has quit [Remote closed the connection]
Wizz_Kidd has joined #ocaml
<Wizz_Kidd> anyone there
<Wizz_Kidd> can ocaml be compiled ?
<Wizz_Kidd> and will it have good performce like c or w/e if it is
ramkrsna has joined #ocaml
dtribble has quit [Read error: 104 (Connection reset by peer)]
Revision17 has joined #ocaml
<mellum> Wizz_Kidd: Yes.
revision17_ has quit [Read error: 110 (Connection timed out)]
Snark has joined #ocaml
pango is now known as pangoafk
<pirata> Whizz_Kidd: yes but no real multithreading
<ulfdoz> Are there efforts including e.g. nptl?
pangoafk is now known as pango
<zmdkrbou> there will never be real multithreading (because of the gc)
<fluxx> never is a strong word.. ;)
<fluxx> although it seems very unlikely judging from the comments from the developers
<fluxx> well, you might be one for all I know ;)
<pirata> Gc could get replaced by a multithreaded one. There seems to be no impetus to do that in the community so it may never happen.
<fluxx> I guess ocaml is still mainly developed by inria.fr, or what kind of community contributions were you thinking of?
<zmdkrbou> yep, that's all the problem : no one seem to be willing to rewrite a gc (the current one is well done and proved with coq ...)
<fluxx> and I imagine supporting two gc's would be too much work
<pirata> There *are* threads in ocaml. They just won't run concurrently. In short, threads are just a convenient programming model in ocaml.
<fluxx> and you can also use multiple processes and message passing (probably wasting some cycles, though)
<fluxx> multicore cpu's are coming though..
<zmdkrbou> fluxx: the licence sucks, so developpers outside of inria .... :\
<ulfdoz> So, ocaml will not profit from the newer hardware develpment like multicore-CPUs.
<pirata> That's one thing stopping me from writing server software in ocaml :(
<fluxx> I'm actually writing something, but it is going to be io bound anyway
<fluxx> the part where it might need cpu is implemented with an external process
<pirata> A real shame, because threads are easier and more portable than IPC
<fluxx> true
<fluxx> but marshalling does ease that quite a lot
<fluxx> if you want to do multiple ocaml processes that is
<fluxx> and process isolation in itself isn't such a bad idea, except for the overhead ;)
pango is now known as pangoafk
kral has joined #ocaml
pangoafk is now known as pango
<pirata> Yes. But this reduces the applicability of ocaml in the industry. In the end, ocaml is an academic attempt at making algebraic specifications workable.
<kral> who said that?
<kral> and in which context?
love-pingoo has joined #ocaml
<pango> I think the Gc of caml light was thread-safe (http://portal.acm.org/citation.cfm?coll=GUIDE&dl=GUIDE&id=158611), so it's not like it wasn't tried before...
<fluxx> otoh, gc's that are thread safe do exist, such as java. though, the requirements for a gc might be somewhat different in ocaml.. (lots of small allocations)
<pango> indeed, actual gc works very well thanks to a very fast path...
<pango> or a very fast fast path ;)
kral has quit [Read error: 113 (No route to host)]
kral has joined #ocaml
revision17_ has joined #ocaml
Revision17 has quit [Read error: 110 (Connection timed out)]
carrumba has joined #ocaml
<Wizz_Kidd> can ocaml be compiled into native machine code
cyyoung has quit ["Leaving"]
<zmdkrbou> * Wizz_Kidd is a bot
<Wizz_Kidd> huh
<ulfdoz> Wizz_Kidd: This was already answered with yes.
<Wizz_Kidd> i was thinking about using ocaml
<Wizz_Kidd> i didnt know
<Wizz_Kidd> sorry :P
<Wizz_Kidd> my 2nd question would be would i be lookign at good perfromnce like i would find with C
<zmdkrbou> already answered too (with mmmh, i would say almost)
<zmdkrbou> :)
<ulfdoz> 99.9% of all apps do not require the speed of C. And Ocaml is around as fast as C++, I think.
<Wizz_Kidd> i seee
<Wizz_Kidd> i guess this might be interesting to use then
<ulfdoz> It is a garbage collected language with a lot of paradigms and therefore has some overhead by nature.
<Wizz_Kidd> i am trying to keep size down also
<Wizz_Kidd> about how big would a hello world be complied down to native machine code
* zmdkrbou *really* think that Wizz_Kidd is a bot
<Wizz_Kidd> sorrrrry again
<Wizz_Kidd> i am always on and off irc
<Wizz_Kidd> and i odnt see anwered question
<zmdkrbou> i think the answer was : 80K
<Wizz_Kidd> how so small
<Wizz_Kidd> like LISP the natively compiled stuff plus runtime is like 15 MB
<Wizz_Kidd> is the runtime attatched to the 80 k
<zmdkrbou> -rwxr-xr-x 1 zmdkrbou users 126K jun 15 11:42 toto << a little bit more when i try
<ulfdoz> mary@waltraud ~ $ ocamlopt hello_world.ml -o hworld
<ulfdoz> mary@waltraud ~ $ ./hworld
<ulfdoz> Hello Worldmary@waltraud ~ $ ls -l hworld
<ulfdoz> -rwx------ 1 mary users 118683 15. Jun 11:42 hworld
<ulfdoz> mary@waltraud ~ $ strip hworld
<ulfdoz> mary@waltraud ~ $ ls -l hworld
<ulfdoz> -rwx------ 1 mary users 82188 15. Jun 11:42 hworld
<zmdkrbou> ho, yep
<zmdkrbou> 80K :)
<Wizz_Kidd> is that compiled ot native machine code?
<zmdkrbou> yes
<Wizz_Kidd> so that would work on any system
<Wizz_Kidd> well linux
<Wizz_Kidd> well whatever you compiled it on
<Wizz_Kidd> i mean the userwouldnt need any extra runtimes or anything right?
<ulfdoz> But in general, I think, binary size doesn't matter, because at runtime a lot of memory can be allocated for other things.
<Wizz_Kidd> so that 80k will work on another computer right with no ocaml installed?
<ulfdoz> According to the ldd output, yes.
<Wizz_Kidd> ldd?
<ulfdoz> mary@waltraud ~ $ apropos ldd
<ulfdoz> ldd (1) - print shared library dependencies
<Wizz_Kidd> i seeeee
<Wizz_Kidd> this felix programming also looks very interesting
Schmurtz has joined #ocaml
<Wizz_Kidd> you make code in a same ML style and it generates c++ code
<Wizz_Kidd> i am not sure how it does it though yet
<Wizz_Kidd> theres a .so file their also which makes me nervous and if it truely translates it
kral has quit ["eating something"]
Wizz_Kidd is now known as Wizz_Kidd-away
pango is now known as pangoafk
pangoafk is now known as pango
pango is now known as pangoafk
pangoafk is now known as pango
SirRobi1 has joined #ocaml
dbueno has quit ["Leaving"]
SirRobi1 has left #ocaml []
pango is now known as pangoafk
pangoafk is now known as pango
Purice has joined #ocaml
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- State of the art IRC"]
dbueno has joined #ocaml
girodt has joined #ocaml
<girodt> hi there. i was wondering how to generate a random int to initialize my random number generator
<zmdkrbou> Random.int :D
<girodt> I know you people like recursive stuff, but isn't it too much ? ;)
<girodt> i'm trying to use Sys.time(), but it always returns 0.05
<Schmurtz> Random.self_init ();
<Schmurtz> "Initialize the generator with a more-or-less random seed chosen in a system-dependent way"
<zmdkrbou> girodt: Unix.gettimeofday()
<girodt> I know this one, but I can't use it in this very much case.
<girodt> zmdkrbou: more interesting
<Schmurtz> girodt why ?
<Schmurtz> it doesn't work on your os ?
<girodt> it works
<girodt> but
<girodt> in my software, I may pass a seed as an argument.
<girodt> the idea is to put a random seed as default value and overwrite this if the argument is passed
<girodt> and then random.init with the seed
<Schmurtz> you may check if there is a seed in argument, then use random.init, and else use random.init_self
* Schmurtz doesn't see where may be the problem
<Schmurtz> however, if Unix.gettimeofday() works, your issue is solved ;)
<girodt> if I use self_init, this will init my PRNG. Then I would need to reinit it with the seed passed as an argument, if a seed is passed.
<girodt> which would be boring because i would have to detect if I passed it or not - breaking my simple and beautiful argument parsing stuff.
<girodt> do i have to load something special to use Unix ?
<girodt> (unix lib i mean)
<zmdkrbou> unix.cma (or .cmxa)
<girodt> okay
<girodt> thanks ! bye.
girodt has quit ["leaving"]
<love-pingoo> some people don't like to stay more than strictly needed..
<love-pingoo> maybe they do real work ?!
* zmdkrbou doesn't believe this
* zmdkrbou sends love-pingoo to his work (articles ... :p)
<love-pingoo> grrr
<zmdkrbou> :)
_fab has joined #ocaml
love-pingoo has quit ["Leaving"]
dbueno has quit ["This computer has gone to sleep"]
rillig has joined #ocaml
Schmurtz has quit [Read error: 113 (No route to host)]
Smerdyakov has joined #ocaml
cyyoung has joined #ocaml
smimou has joined #ocaml
love-pingoo has joined #ocaml
pango is now known as pangoafk
asymptote has joined #ocaml
<Smerdyakov> Sweet. I have #2 Google hit for "wonders of functional programming," and I wasn't even trying to!
pangoafk is now known as pango
asymptote has quit ["Leaving"]
Smerdyakov has quit ["Leaving"]
Purice has quit ["Leaving"]
finelemon has joined #ocaml
Smerdyakov has joined #ocaml
finelemo2 has joined #ocaml
finelemo1 has quit [Read error: 110 (Connection timed out)]
finelemon has quit [Read error: 110 (Connection timed out)]
shawn has quit ["This computer has gone to sleep"]
_fab has quit [Read error: 110 (Connection timed out)]
kral has joined #ocaml
_fab has joined #ocaml
slipstream-- has joined #ocaml
Snark has quit ["Leaving"]
slipstream has quit [Connection timed out]
love-pingoo has quit ["Connection reset by by pear"]
kral has quit ["Live fast, die young."]
revision17_ has quit ["Ex-Chat"]
ulfdoz has quit [kornbluth.freenode.net irc.freenode.net]
ulfdoz has joined #ocaml
_fab has quit [Remote closed the connection]
carrumba has quit [Read error: 113 (No route to host)]
Ali`` has joined #ocaml