<jdrake>
"In large part, the purpose of such a site should be to convey that ocaml is a living, breathing animal. But the frozen newsfeed on the site will most definitely achieve the opposite effect " hmm exactly what I have been thinking whenever going there
<debona|r>
can someone show me some different ways of writing the same thing?
<debona|r>
pointers?
Smerdyakov has joined #ocaml
<debona|r>
hey Smerdyakov
<jdrake>
ah, figured it out: select as normal, but hold option and left click to paste
<jdrake>
debona|r, i can just once i figure out how to express it
<debona|r>
jdrake: what do you mean? 2 to the power of 3 ... 2 * 2 * 2
<jdrake>
where is a list of math functions
<debona|r>
I wanted to write it on my own... just to use iteration etc
<jdrake>
oh i see
<jdrake>
either way, what is the equivalent function for ln?
<debona|r>
but that said, I was wanting someone with more experience to tell me how it could be made better
<jdrake>
i can't find it anywhere
<debona|r>
or different even
<jdrake>
you know the relationship between exp / ln and the operation x ^ y right?
<debona|r>
i'm not sure I should claim to know anything :P
<debona|r>
but mathematically, sure
<debona|r>
although it's been awhile
Naked has joined #ocaml
<jdrake>
let ( ^. ) x y = exp (y *. log x);;
<jdrake>
not that it works exactly
<jdrake>
but as close as I guess it could come: # 2.0 ^. 3.0;;
<jdrake>
- : float = 7.99999999999999822
<jdrake>
here we go :-) let ( ^ ) x y = int_of_float (exp (float_of_int x) *. log (float_of_int y) );;
<jdrake>
quite ugly
Hadaka has quit [Read error: 111 (Connection refused)]
Naked is now known as Hadaka
<ofranja>
these 'x_of_y' functions are the ugliest.
<ofranja>
not to mention that, if you're implementing a 'to_string' function, they usually take a lot of lines of code.
wmg has joined #ocaml
<debona|r>
I think I like my method better :P
<debona|r>
course, my returned 16
<debona|r>
which is really 2^4
<debona|r>
hm
<debona|r>
it doesn't actually even do what I wanted
<debona|r>
doh
<debona|r>
haha
wmg has left #ocaml []
<debona|r>
ok, bedtime
not_me2 has quit [Remote closed the connection]
not_me2 has joined #ocaml
Snark has joined #ocaml
Lemmih_ has joined #ocaml
ita has joined #ocaml
<ita>
hi all
<ofranja>
ppl, i'm having a problem concerning Unix.create_process. it opens the process but doesn't exit when process terminates.
<ofranja>
i'm passing /usr/bin/true as the program to run, and tried with various file_descr: /dev/null, /dev/zero and standard in/out/err.
<ita>
ofranja: keep trying while keeping an eye on the doc, i'm sure you'll manage to find a solution :)
<ofranja>
actually, let me correct myself: *the process* doesn't exits. since /bin/true just exit with a zero status code, it should.
<ofranja>
well, it's not a documentation issue, i guess. this only happens when i open more than one child.
<ofranja>
with just one child open, everything runs fine.
ita has quit ["Lost terminal"]
<ofranja>
a quick look at 'ps', shows the various 'ocamlrun' processes that haven't returned. and they aren't zombies.
<mflux>
ofranja, you need to 'wait' (or 'waitpid') for the process to get rid of the zombie, which holds the return value of the process
<ofranja>
yes, that's the point. waitpid doesn't return the processes.
<mflux>
doesn't return?
<ofranja>
yes.
<ofranja>
i even got one Unix.Unix_error(ECHLD,_,_) exception after 3 childs returned. but i have opened 15.
<ofranja>
i've reimplemented this part of the code as a test program, but i can't find out the problem.
<mflux>
let devnull_in = Unix.openfile "/dev/null" [Unix.O_RDONLY] 0 and devnull_out = Unix.openfile "/dev/null" [Unix.O_WRONLY] 0 and process = Unix.create_process "/bin/true" [||] devnull_in devnull_out devnull_out;; and then Unix.waitpid [] process;; works for me
<ofranja>
it's just one process.
<ofranja>
one process is fine.
<mflux>
so the problem appears only with many processes?
ita has joined #ocaml
<ofranja>
yes.
<ita>
grr fsc#*! connection
<mflux>
short or long-lived?
<ofranja>
very short.
<ofranja>
/usr/bin/true
<ita>
ofranja: add flush_all ();; (one never knows, it solved my all my problems yesterday :)
<ofranja>
didn't change a bit.
<ofranja>
17373 pts/21 R 0:12 /usr/bin/ocamlrun ./t
<ofranja>
there are ~6 like this one running.
<mflux>
let's say I have:
<mflux>
let rec processes n = if n > 0 then (Unix.create_process "/bin/true" [||] devnull_in devnull_out devnull_out)::(processes (n - 1)) else [];;
<mflux>
let wait l = List.map ( fun p -> (Unix.waitpid [] p)) l;;
<ofranja>
funny. kill -TERM doesn't seem to affect them.
<mflux>
this works: wait (processes 20);;
<mflux>
are they zombies?
<ofranja>
nope.
<ofranja>
very strange.
jason_ has quit ["Client Exiting"]
<ofranja>
but you are doing it another way.
<ofranja>
i'm calling waipid with [ WNOHANG ] and -1 as arguments.
<mflux>
are you sure you're not calling it too soon?
<mflux>
so if you have 20 processes and you call it 20 times, but for the first call the first process has not yet exited
<ofranja>
yes, like this. actually, the program in question open a bunch of processes, then, it gets the pids that are no longer running (that's why the "WNOHANG". the process must not block). then it loops again and keep doing this cycle, until all processes have been launched. when getting to this point, it simply waits the rest.
<ofranja>
it makes use of the non-blocking waitpid's capabilities so it doesn't have to be multi-threaded.
<ofranja>
the problem is that it was locking at some places, because of processes not returning.
<ofranja>
when searching for the problem, i found this behaviour at waitpid.
bk_ has joined #ocaml
<ofranja>
interesting, i think i found the problem.
<ofranja>
but it's a bit non-sense.
<ofranja>
removing a harmless a := b from the code solves the problem, but it is very strange: this atribution shouldn't affect the code.
<ofranja>
in fact, the only thing that changes is a prerr_endline!
<mflux>
can you make a smaller test case that demonstrates the problem?
<ofranja>
yes, i have one here?
<ofranja>
yes, i have one here. wanna see it?
<mflux>
well, why not
<ofranja>
i'm trying to reproduce the problem modifying the code you pasted here, so i can see what is the real reason of the problem.
<mflux>
but does it have anything to do with create_process or waitpid anymore?
<mflux>
if the assignment was the trouble maker ;)
<mflux>
I can't say about the others, but I personally have gained the level of self-awareness.
_fab has joined #ocaml
avn has quit ["leaving"]
<jdrake>
in reading a tutorial it tries to explain boxed and unboxed types, but it doesn't quite explain it enough
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
ronwalf has quit [Read error: 110 (Connection timed out)]
<ofranja>
jdrake: i saw you were looking for a ocaml IDE. well, i use nano to edit the code, most of the time, but there is a program called mlglade which converts a glade file into ocaml code.
avn has joined #ocaml
<ofranja>
the code is in lablgtk1 flavour, but you just have to change some optimal arguments, and replace some names that has changed (notably the textbox name).
<ofranja>
port the mlglade to lablgtk2 / glade2 is an option, too, because it just have to parse the XML and generate the code (and there are some ready xml libraries for ocaml).
FredCods has quit [Read error: 110 (Connection timed out)]
ronwalf has joined #ocaml
FredCods has joined #ocaml
_fab has quit [Read error: 110 (Connection timed out)]
<jdrake>
ofranja, interesting, might look into that.
<mflux>
mm. let's say I have type t = { foo : int; bar : int };; and let a = { foo = 42; bar = 10 }; , now can I define b so that I make a copy of a but modify one field, without writing out the other field in a?
<Riastradh>
I don't think so.
<mflux>
similar to what one can do with objects, {< a = 42 >}
<mflux>
too bad ;)
<mflux>
I suppose I won't be filling that 4-field record one by one then
<Riastradh>
You can in SML!
<mflux>
;(
<mflux>
I wonder how much space does 10k hash tables take compared to 10k 4-field records
<Riastradh>
Um, quite a lot more, I'm sure.
<mflux>
I suppose I'll settle to lists
<karryall>
let b = { a with foo = 32 }
<karryall>
is it what you want ?
<mflux>
it would look very much like it
<mflux>
thanks
<mflux>
..although the solution with lists might still actually be better
<Riastradh>
Why?
<mflux>
I'm parsing nntp articles
<mflux>
thought first of using article with a fixed set of fields
kosmikus is now known as kosmikus|away
maihem has joined #ocaml
karryall has quit ["tcho"]
mrsolo has quit [Connection reset by peer]
FredCods_ has joined #ocaml
FredCods_ is now known as ghost
ghost is now known as FredCods_
FredCods has quit [Nick collision from services.]
FredCods_ is now known as FredCods
mattam_ has joined #ocaml
karryall has joined #ocaml
jason has joined #ocaml
GreyLensman has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
mrsolo has joined #ocaml
mrsolo has quit [No route to host]
_fab has joined #ocaml
cjohnson has joined #ocaml
FredCods has quit [Read error: 60 (Operation timed out)]
FredCods has joined #ocaml
CosmicRay has quit ["Client exiting"]
FredCods_ has joined #ocaml
FredCods has quit [Nick collision from services.]
FredCods_ is now known as FredCods
GreyLensman has quit ["Leaving"]
maihem has quit ["Read error: 54 (Connection reset by chocolate)"]
ofranja has quit ["."]
monotonom has quit ["Don't talk to those who talk to themselves."]
vezenchio has quit ["With little power comes little responsibility"]
vezenchio has joined #ocaml
smimou has quit ["?"]
vezenchio has quit ["With little power comes little responsibility"]