<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');;
<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.
<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