nysin has quit [kornbluth.freenode.net irc.freenode.net]
ejt has quit [kornbluth.freenode.net irc.freenode.net]
srv has quit [kornbluth.freenode.net irc.freenode.net]
nysin has joined #ocaml
ejt has joined #ocaml
srv has joined #ocaml
nysin has quit [kornbluth.freenode.net irc.freenode.net]
srv has quit [kornbluth.freenode.net irc.freenode.net]
ejt has quit [kornbluth.freenode.net irc.freenode.net]
nysin has joined #ocaml
ejt has joined #ocaml
srv has joined #ocaml
jdmarshall has quit [Remote closed the connection]
jdmarshall has joined #ocaml
Nutssh has left #ocaml []
The-Fixer has joined #ocaml
jdmarshall has quit ["ChatZilla 0.9.52B [Mozilla rv:1.6/20040113]"]
The--Fixer has joined #ocaml
The--Fixer has quit [Remote closed the connection]
The-Fixer has quit ["Goodbye"]
gt2 has joined #ocaml
axolotl has quit [Remote closed the connection]
wax has joined #ocaml
mimosa has joined #ocaml
<pattern>
let ( q,r ) = divide ( int_of_string a ) ( int_of_string b ) in
<pattern>
print_string ( a ^ " / " ^ b ^ " = " ) ;
<pattern>
print_string ( string_of_int q ) ;
<pattern>
print_string ( " * " ) ;
<pattern>
print_string ( b ) ;
<pattern>
print_string ( " + " ) ;
<pattern>
print_endline ( string_of_int r )
<pattern>
is there a better way to construct strings than what i'm doing here?
<pattern>
err... i guess i could use sprintf
<pattern>
nevermind :)
mimosa has quit ["J'ai fini."]
mimosa has joined #ocaml
gt2 has quit [Read error: 110 (Connection timed out)]
The-Fixer has joined #ocaml
Kinners has joined #ocaml
tomasso has joined #ocaml
SeaKai has joined #ocaml
karryall has quit ["."]
mattam has joined #ocaml
gt2 has joined #ocaml
mattam_ has quit [Read error: 60 (Operation timed out)]
Kinners has left #ocaml []
karryall has joined #ocaml
wats`tralali has quit ["Ein Dieb ist jemand, der die Angewohnheit hat, Dinge zu finden, bevor andere Leute sie verlieren"]
gim has joined #ocaml
buggs^z is now known as buggs
SeaKai has left #ocaml []
housetier has joined #ocaml
nysin has left #ocaml []
Potasso has joined #ocaml
Potasso has quit []
Nutssh has joined #ocaml
nysin has joined #ocaml
wazze has quit ["Ein Dieb ist jemand, der die Angewohnheit hat, Dinge zu finden, bevor andere Leute sie verlieren"]
<mrvn>
How do I scanf a Int64.t?
<Nutssh>
I used Int64.of_string
<mrvn>
%lld does not work but %Ld is what I need.
gt2 has quit [Connection timed out]
nysin has left #ocaml []
slashvar has quit ["reboot"]
karryall has quit ["."]
whiskas has joined #ocaml
Nutssh has quit ["Client exiting"]
ejt has quit [Read error: 60 (Operation timed out)]
ejt has joined #ocaml
gt2 has joined #ocaml
<mrvn>
How do I mmap something?
* Smerdyakov
shudders.
<Smerdyakov>
Personally, perhaps only for aesthetic reasons, I would recommend abstracting that all behind an interface to some C code.
<mrvn>
I have to parse some 5-20MB big RFC822 formated text files.
<mrvn>
Probably should write the parser in C too and provide a Hashtbl like interface for it.
<Smerdyakov>
To do it nicely with OCaml, you'd need fancy integration with the garbage collector, I'd think.
<mrvn>
There was a way to add a function to an object that gets called when the GC deletes th object, right?
<Smerdyakov>
Or something that's not easy to just add on, since you'd be interacting with things outside the usual heap.
<Smerdyakov>
I think so.
<Smerdyakov>
For instance, for this to be type safe, the mmap'd region needs something like an array size, to make accesses to it safe.
<mrvn>
So I could make a mmap oject with C interface and make it unmmap on delete.
<Smerdyakov>
I guess so!
<mrvn>
An mmap should be the same interface as big arrays.
<Demitar>
mrvn, perhaps it could even be a bigarray?
<Demitar>
The mmap call being done in C of course.
<mrvn>
I would have to look into it but yes, very likely.
<mrvn>
Instead of malloc/free in C you would have mmap/unmmap in C.
<mrvn>
Whats the best way to split a list into lists of size max_batch?
<Demitar>
C or OCaml?
<mrvn>
ocaml
<Demitar>
"best" is a rather large word. :)
<mellum>
No, it has only 4 characters
<Demitar>
mellum, I actually considered and discarded that implication. :)
<whiskas>
mellum: Hmm, I remember seeing you somewhere else :-)
<mellum>
whiskas: might be
<Demitar>
mrvn, don't know about "best" but it feels like a recursive function with an accumulation which is a list of lists.
<Demitar>
s/tion/tor/
<mrvn>
Demitar: I was thinking of doing it destructively but thats a big hack.
<Demitar>
mrvn, it assumes it will be garbage collected during the construction, otherwise I can't see any gain, or?
<mellum>
mrvn: you can use Extlib'
<mellum>
s split_nth
<mrvn>
is that a standard module?
<mellum>
not quite
<Demitar>
mrvn, by the way 29.2.3 in the manual should give you what you want for your mmapping, alloc_bigarray() specifically.
<mrvn>
Demitar: Saw that too. But thanks anyway.
<Demitar>
mrvn, makes me want to toy with mmap() too, but I have no use for it. :)
<mrvn>
Did I mention that I hate it when I forget to terminate the recursion?
<Demitar>
*grin*
<Demitar>
Especially wonderful when it's tail-recursive. :)
<mrvn>
It is and forks an rsync every time.
<whiskas>
:-))
<Demitar>
Hint, don't do this: let func = ref (fun () -> ()) in func := (fun () -> <...>; !func); !func (); when you want to chain function calls. ;-)
<Demitar>
s/!func);/!func ());/ naturally.
<mrvn>
Aeh? Why not?
<mrvn>
That calls it self over and over?
<Demitar>
It evaluates !func late and at that point it's bound to itself effectively turning it into an infinite recursion.
<whiskas>
What does fun () -
<whiskas>
Argh.
<Demitar>
A grand example of why you shouldn't mix imperative and functional code. ;-)
<whiskas>
Again, what does fun () -> <...>;!func mean?
<whiskas>
Ah, wait, !func I know, but fun () -> <...>?
<mrvn>
let add_func f func = let f2 = !func in func := (fun () -> f (); f2 ())
<mrvn>
; func
<Demitar>
<...> is merely ircism saying "add contents here". :)
<mrvn>
That should do the trick, or not?
<whiskas>
Ah, ok :-)
<Demitar>
mrvn, yes, but doing a polymorphic function adder is even more fun. :)
<mrvn>
I prefer CPS style for that.
<Demitar>
Actually what I was thinking of was function chaining, so ignore that. ;-)
<mrvn>
let id x = x (* Identity function *)
<mrvn>
let ($) f g x = f (g x) (* Functional composition *)
<mrvn>
let format k () = k id "" (* output to string *)
<mrvn>
Stuff like that looks realy cryptic. :)
<Hadaka>
it does?
<Hadaka>
well, the last one does...
<mrvn>
Hadaka: let ip_parser = int$dot$int$dot$int$dot$int (fun a _ b _ c _ d -> IP.make a b c d);
<Hadaka>
mrvn: cool
<mrvn>
Typesave IO without the drawbacks of format strings. :)
<mrvn>
s/int/int8/ to be precise.
<Demitar>
Yes, rather than a cryptic "%i.%i.%i.%i" we have an easy to understand int$dot$int$dot$int$dot$int. ;-)
<mellum>
what happens if I feed it "turtle power!!!"?
<mrvn>
mellum: Throws an exception.
<mrvn>
Demitar: Nice and cryptic. The advantage is that you can do the IO asyncronous.
<mrvn>
You call the reader with the parser function and it stores it. The main event loop then reads the chars and at some later time the function in the parser gets called with the read values.
<Hadaka>
almost like continuations, except not ;)
<mrvn>
CPS - Continuation Passing Style.
<mrvn>
It is exactly that.
whiskas has quit ["Pa / Bye."]
karryall has joined #ocaml
Defcon7 has quit [Read error: 110 (Connection timed out)]