Alpounet changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | 3.11.1 out now! Get yours from http://caml.inria.fr/ocaml/release.html - Answer OCaml Meeting 2010 poll https://forge.ocamlcore.org/survey/survey.php?group_id=77&survey_id=1
sramsay_ has quit ["Leaving"]
ikaros has quit ["Leave the magic to Houdini"]
onigiri has quit []
slash_ has quit [Client Quit]
munga has quit [Read error: 145 (Connection timed out)]
kaustuv_ has joined #ocaml
kaustuv_` has quit [Read error: 60 (Operation timed out)]
rwmjones_lptp has quit ["This computer has gone to sleep"]
antegallya has joined #ocaml
antegallya has quit [Client Quit]
tmaeda is now known as tmaedaZ
atol has quit [Read error: 131 (Connection reset by peer)]
verte has joined #ocaml
_unK has quit [Remote closed the connection]
verte is now known as verte-work
palomer has quit [Read error: 110 (Connection timed out)]
eldragon has left #ocaml []
travisbrady has quit []
tmaedaZ is now known as tmaeda
travisbrady has joined #ocaml
mfp has quit [Read error: 110 (Connection timed out)]
mfp has joined #ocaml
Amorphous has quit [Read error: 110 (Connection timed out)]
Amorphous has joined #ocaml
valross has joined #ocaml
caligula_ has joined #ocaml
thrasibule has joined #ocaml
caligula__ has quit [Read error: 110 (Connection timed out)]
thrasibule_ has joined #ocaml
thrasibule has quit [Read error: 104 (Connection reset by peer)]
verte-work has quit [Remote closed the connection]
verte-work has joined #ocaml
travisbrady has quit [Read error: 60 (Operation timed out)]
tmaeda is now known as tmaedaZ
travisbrady has joined #ocaml
tmaedaZ is now known as tmaeda
verte-work has quit ["~~~ Crash in JIT!"]
verte has joined #ocaml
BigJ2 has joined #ocaml
mjonsson has quit [Remote closed the connection]
Alpounet has quit ["Leaving"]
valross has quit [Remote closed the connection]
verte has quit ["~~~ Crash in JIT!"]
mishok13 has joined #ocaml
jonafan has quit [Read error: 104 (Connection reset by peer)]
julm has joined #ocaml
ttamttam has joined #ocaml
valross has joined #ocaml
kaustuv_` has joined #ocaml
valross has quit [Read error: 110 (Connection timed out)]
valross has joined #ocaml
kaustuv_ has quit [Read error: 110 (Connection timed out)]
Submarine has quit [Read error: 110 (Connection timed out)]
Mr_Awesome has quit ["aunt jemima is the devil!"]
Vital303 has joined #ocaml
Submarine has joined #ocaml
BiDOrD has quit [Read error: 110 (Connection timed out)]
BiDOrD has joined #ocaml
valross has quit ["Ex-Chat"]
verte has joined #ocaml
ikaros has joined #ocaml
rwmjones_lptp has joined #ocaml
ikaros has quit ["Leave the magic to Houdini"]
ikaros has joined #ocaml
waleee_ has joined #ocaml
waleee_ has quit [Client Quit]
waleee has joined #ocaml
<waleee> quick question: why doesn't Array.make_matrix work with other types than int (I'm using ocaml 3.11.1) ? Array.make x ( Array.make x here_is_the_type) works
<waleee> ehm ... nevermind
albacker has joined #ocaml
tmaeda is now known as tmaedaZ
<flux> :)
Associat0r has quit []
thrasibule_ has quit [Read error: 60 (Operation timed out)]
thrasibule has joined #ocaml
ztfw has joined #ocaml
thrasibule has quit [Read error: 110 (Connection timed out)]
travisbrady has quit [Read error: 145 (Connection timed out)]
mrvn has joined #ocaml
<mrvn> Hi.
rwmjones_lptp has quit ["This computer has gone to sleep"]
<mrvn> How do I get a char as signed int? How do I convert 2 chars to signed 16bit int?
tmaedaZ is now known as tmaeda
<mrvn> i.e. how to sign extend 8/16 bit to 31
<thelema> if c land 127 then c lor min_int + 127 else c
<thelema> err, land 128
<thelema> c land 128 != 0
<mrvn> Currently I have if c >= 128 then c - 256 else c
<thelema> c-256? somehow I don't think that's right
<mrvn> 128 -> -128, 255 -> -1
<mrvn> I was hoping for something that would make the compiler emit a sign extend opcode for the cpu.
<thelema> C
<mrvn> calling a C function is way to expensive
verte has quit ["~~~ Crash in JIT!"]
<thelema> then you're stuck with this, unless you want to extend the ocaml code gen
<mrvn> :( Too bad.
<mrvn> Any tip for 32bit unsigned int?
<mrvn> and 64bit unsigned come to thing of it
* thelema looks in codegen
waleee has quit ["leaving"]
_andre has joined #ocaml
<mrvn> WTF? 'int_of_char str.[off]; str.[off] <- char_of_int v' is slower than external get_uint8_le : string -> int -> int = "get_8_le_unsigned" "noalloc"
<mrvn> external set_uint8_le : string -> int -> int -> unit = "set_8_le_unsigned" "noalloc"
<mrvn> 38s vs. 45s for 10000000 repeats on 64 bytes.
<mrvn> aeh, 45s vs 38s I mean.
<thelema> mrvn: interesting... I guess C isn't that slow
<mrvn> but faster?
<thelema> char_of_int should be free, but mutating the string might be expensive in ocaml
<thelema> it shouldn't be that expensive, but apparently more than in C
<mrvn> why? strings are mutable. doesn't copy it.
<thelema> shifting & masking?
waleee has joined #ocaml
<thelema> it's not starting off with a char, so alignment...
<mrvn> huh?
<thelema> it starts with a wird having 31-bits of data
<mrvn> char_of_int isn't free as it checks bounds. But s.[x] <- c sould just write the byte.
<thelema> it has to turn that into a char
<mrvn> The c code too.
<mrvn> t1 = Int_val(ml_x);\
<thelema> hmmm...
<mrvn> I don't range check so that might make C faster.
<mrvn> get_uint8_le 19.646s, int_of_char str.[off] 17.554s
<mrvn> set_uint8_le 38.767s, str.[off] <- char_of_int x 41.885s
<Camarade_Tux> loop unrolling?
<mrvn> args. found a bug in my test cases.
<mrvn> The first numbers (get+set together) had a partial application for the get.
<mrvn> So it only tested set.
<mrvn> array bounds checks as well in the ocaml case while C just writes the byte.
jonafan has joined #ocaml
<mrvn> and: 4034a0: e8 1b 0f 00 00 callq 4043c0 <camlPervasives__char_of_int_144>
<mrvn> Val_unit is 0x00000001, right?
<Camarade_Tux> 0
<mrvn> 4034b4: 48 c7 c0 01 00 00 00 mov $0x1,%rax
<mrvn> 4034bb: 48 83 c4 18 add $0x18,%rsp
<mrvn> 4034bf: c3 retq
<Camarade_Tux> I mean 0x0....0
<mrvn> Then what is that on a unit returning function?
Alpounet has joined #ocaml
<mfp> Camarade_Tux: AFAIK Val_unit is 0x1 = 0 in OCaml
<Camarade_Tux> mfp: hmmm, Val_int(0) in C is unit I think
<mrvn> yes and 0x0000000 would be a pointer to 0.
<mfp> and Val_int(0) is (0 << 1 | 1) = 0x1
<Camarade_Tux> gc ?
<mfp> tagged arithmetics, yes
<mrvn> Why they don't tag pointers with 1 I still don't get
<mfp> and 0 for ints?
<mrvn> 0 for everything else.
<mfp> still have to bitshift, and you can combine the (-1) in a single instruction anyway (lea9
<mfp> (lea)
<mrvn> or 11 for pointer, 0 for int, 10 for other
<mrvn> mfp: a+b -> a+b-1
<mfp> and?
<mrvn> If you zero tag ints then a+b stays a+b
<mfp> it's still 1 instruction with 1 as the tag leaq -1(%rax, %rbx), %rax
<mrvn> A+b?
<mrvn> a*b?
<mfp> and you still have to shift for mul and div, with 0 as the tag
<mrvn> (a-1)*(b/2) vs a*(b/2)
<mfp> a/2 * b
<mrvn> mfp: b is tagged. That would add tag * a
<mfp> my bad
<mrvn> actually (a-1)*(b/2)+1 vs a*(b/2)
<mfp> mul + 1 is lea
<mrvn> a/b is (a/2)/(b/2)*2+1 vs. (a/(b/2))&~0x1
<mrvn> How do you do mul with lea?
<mfp> sorry, misread
<mfp> it's 1 right shift, 1 dec, 1 mul, 1 inc
<mfp> vs. 1 shift, 1 mul
<mrvn> and I think all pointer access is with a small const and 2 registers.
<mrvn> e.g. 17(%rax, %rbx)
<mfp> one advantage of untagged pointers is that you can pass C pointers unmodified
<mrvn> true. Might be the deciding factor.
<mrvn> A optimizing compiler should untag integers for the duration of a mathematical expression so the tag might not matter.
<mrvn> anything between allocating calls actually.
<mrvn> timing results.
<mrvn> Seems like for anything but (u)int8 C code is faster.
kaustuv_` has quit ["ERC Version 5.3 (IRC client for Emacs)"]
<mrvn> string needs unsafe_get and unsafe_set
<mfp> mrvn: does that hold if you unroll the loop manually a bit?
<mrvn> The for i = 0 to 63 do fn s (i * size); done; one?
<mfp> (I'd expect pure-OCaml to become faster relative to external, maybe, if OoO exec is working)
<mfp> haven't seen the benchmark code
<mfp> did you paste it somewhere?
<mfp> external get_uint32_be : string -> int -> int32 -> unit = "get_32_be_unsigned" "noalloc" <- wrong type?
<mfp> -> unit ...
<mrvn> No, that code is evil as it modifies the argument passed in
_andre has quit ["Lost terminal"]
<mfp> to avoid alloc, I see
<mrvn> Which I think makes no sense. let x = Int32.zero in get_uint32_le str off x; x just allocs anyway.
<mrvn> But maybe calling the GC from ocaml is faster than from C.
<mfp> only if you can chain get/set + some arithmetics, maybe
<mfp> the compiler sometimes performs Int32's arith without alloc
<mrvn> But it can't when you pass it to C
<mfp> right
<mfp> that's what I was going to say, that set would force allocation and kill perf
<mrvn> And how does the compiler know x gets modified? Isn't int32 ment to be a functional type?
<mfp> as would allocating in C, since you cannot use noalloc, and then you get a ~30 instruction (IIRC) prologue
<mrvn> or what about get_uint32_le str off (int32_of_int 17)? I would rather have that give an error.
<mfp> it cannot, so you could get broken code if it decides to reuse the value in some register
<mfp> instead of reloading
<mrvn> mfp: The prologue is the reason for the "noalloc". I got the code from somewhere else but I think that is too dangerous.
<mfp> it is
<mrvn> at the bottom it also says: /* Special care needs to be taken on ARCH_ALIGN_INT64 platforms (hppa and sparc in Debian). */
<mrvn> and then it mallocs.
<mrvn> CAMLreturn(caml_copy_int64(r)); \
<mfp> now, if you used int32 ref (which is more or less equiv to using a new custom type),
<mfp> (as an abstract type)
<mrvn> int32 ref is a double indirection. bah.
<mfp> then custom type
<mfp> int32 ref just as a proof of concept
<mrvn> Personally I think I won't need int32 at all. Things are eigther ints or int64.
<mfp> don't you have the same problem with int64?
<mrvn> yes
<mrvn> With the bonus that on hppa and sparc the hack doesn't seem to work due to alignment constraints.
<mrvn> I won't use the int32/int64 preallocated hack. Just too dangerous.
<mrvn> Heres a GC question: Say I allocate a string manually in C, outside the GC heap, then the GC won't move that around, right?
<mrvn> Will it free the string when nobody uses it anymore?
<mrvn> getting uint8 from: Ocaml string 17.433s, int8_unsigned Bigarray 54.855s. I guess BigArray is out.
_zack has joined #ocaml
infoe has quit [Read error: 54 (Connection reset by peer)]
<thelema> difference between tagging pointers or ints is tradeoff between slower dereferencing of pointers vs. slower math
<mrvn> thelema: is it? pointer dereferencing is usualy done with a constant offset. Just decrease that by the tag.
<thelema> hmmm, but the pointer itself might have to be word aligned.
<thelema> and the offset is words, not bytes, no?
<mrvn> not on any hardware I know to still be in use
<mrvn> thelema: i think it is bytes. only the register offset is shifted or not?
<mfp> mrvn: "allocate manually"? do you mean mallocing and adding a fake string block header + the word terminator at the end?
<mrvn> mfp: yes.
<mfp> it won't free it
<thelema> mrvn: C compatibility is nice, but it wouldn't be too costly to convert in the interface
<mrvn> thelema: just like non pointer has to be converted anyway. :)
<thelema> so the tradeoff is in foreign interface, what has to be converted...
<mfp> and it won't move it either --- as long as it's outside the caml heap, the GC will just ignore it, so no compaction, no collection
<mrvn> and writing the GC (or any other C part)
<thelema> ah, integers would have to be 31-bit anyway, with a zero bit at the end.
<mfp> and if it had pointers inside, no traversal either, you'd have to register the roots manually
<thelema> if you tagged pointers, you'd still have to tag with 0 integers
<mrvn> thelema: it would add un-tagging pointers for C stubs and save on some math.
<mrvn> mfp: how would a string have pointers in it?
<mrvn> mfp: But generally, a pointer pointing outside the GC heap is not inspected?
<mfp> mrvn: it won't. I mean, if you allocated a block that could have (such as an array), ...
<mfp> it's ignored, yes
<thelema> what's the most efficient approximate sorting algorithm for nearly sorted data?
<mrvn> thelema: let fun x = x
travisbrady has joined #ocaml
<mfp> so if you do the same "fake allocation" for an array, you'll have to register each slot as a root
<mrvn> mfp: urgs. I thought it would always look at the block tag and then decide.
<thelema> mrvn: good. What's a good one that actually makes progress?
<mfp> nope, IIRC it checks if it's in the page table before
<mrvn> thelema: I only know real sorting algorithms.
* mfp checks
<mfp> thelema: Timsort
<thelema> ok, just checking. I don't want to maintain my heap, but want to be able to find hihg-ranking values quickly
<thelema> Okay, I'll admit that's pretty efficient for nearly sorted data...
* thelema knows timsort, but can't see an easy way to reduce its complexity with fewer rounds or anything..
<mrvn> thelema: use a fibbonachi heap or so.
<thelema> hmm, I have code for that, but I have to be able to update the rankings, and that seemed... hard
<mrvn> so you need a priority queue where the priority changes over time?
<thelema> yes, and I've written one, but it's not functional - I'm doing branch and bound and want different priority orderings in different subtrees
tvn2009 has joined #ocaml
<mrvn> I've once done a bubble-heap. When I update a priority the item can move in the heap up or down a bit. Like a buble rising or falling.
<mrvn> Seems to work well when the priorities change often but little.
<thelema> yes, that's what I'm doing. I learned it as "percolate"
<thelema> percolate up/down
<thelema> but this is very non-functional. At least it's pretty cheap to clone the heap array and lookup array
ikaros has quit ["Leave the magic to Houdini"]
<mrvn> pretty impossible otherwise.
<thelema> ok, thanks for thinking about it.
<mrvn> To be functional you need to always walk till the root.
<mrvn> And then you have a tree. Inserts must start at the root, go down and come back too.
<thelema> the walking isn't a problem, the problem is how to do lookups into the tree?
<thelema> remember a binary path (left, right, left, left)?
<mrvn> remember a key. lookup in log n
<mrvn> or rther a pointer to the priority
<mrvn> I would think hard about making this functional.
<thelema> with a pointer to the priority, I can update the priority, but I have to change the tree, and to do this, I have to have either a doubly-linked tree (not very functional) or a path...
BiDOrD has quit []
<thelema> maybe the path idea isn't bad.
<thelema> although updating the paths will be a pain.
<mrvn> thelema: you get the priority, then you search the tree for the priority to remove the item and then reinsert it.
<mrvn> a balanced tree with key (priorty, unique id)
<thelema> search the tree? I'm using a binary tree, not a heap?
<mrvn> if you can have priority collisions
<thelema> I will have lots of priority collisions
<mrvn> thelema: The problem is you can use an array for functional unless you copy the array every time.
<mrvn> can't
<thelema> yup.
<mrvn> that only leaves you with a tree
<thelema> maybe I need to spend more time preventing array copying
infoe has joined #ocaml
<thelema> It's possible to use trees for heaps - it's the example in 2.1 of the manual
<mrvn> Why do you need it to be functional?
<thelema> so I can have different priorities of the "next" search item in different parts of my search tree
<mrvn> so when the priority of an item changes you copy the item?
<thelema> when I take a right branch, I copy the whole heap structure so I can reweight it.
<mrvn> oehm, how do you do that with an array?
<mrvn> The right branch is like off+1, off+3, off+4, off+8, off+9, off+10, off+11, off+16, off+17...
<thelema> ? Array.copy
<mrvn> (ups, thats left)
<thelema> "
<thelema> "take a right branch" refers to the higher-level search algorithm going on in a *huge* tree
<mrvn> oh, misread. Thought you only cpied the branch but you said whole heap.
<mrvn> Maybe use a b-tree where each node contains a heap? Would that be workable?
<mrvn> otherwise, as said, fibbonacci trees
<thelema> what's nice about fibbonacci trees?
<mrvn> The nice part is that it supports "decrease key"
<thelema> I have to increase keys too...
<mrvn> If you increase a key you might have to cut all children. I think that violates the amortized costs.
<mrvn> So might be a bit more expensive than thought
<thelema> I can try it with judt decreasing keys, but I really want to shuffle around priorities.
<thelema> I want to avoid 1st and second neighbors, but head towards 3rd nrighbors
<mrvn> You also have to work out how to eliminate the double linked lists or copy them completly.
<thelema> (in a graph)
<thelema> yes, I'll look down other paths.
<mrvn> Each node has at most log(n) children and I think the height is similary bound. Might take log n * log n copies to make it functional.
<mrvn> The "functional" part makes it really hard. I think all the normal algorithms you learn about are not functional.
<thelema> yup
<thelema> I'm going to see if I can mutate the state one way, and reverse the mutations as I backtrack...
<mrvn> brendan: unless you work on a Indy over serial console, in which case it goes into the bios.
<mrvn> ups
waleee has quit ["Lost terminal"]
_unK has joined #ocaml
lutter has joined #ocaml
tmaeda is now known as tmaedaZ
ttamttam has quit ["Leaving."]
ztfw has quit [Connection reset by peer]
ztfw has joined #ocaml
lutter has quit ["Leaving."]
mishok13 has quit [Read error: 60 (Operation timed out)]
_zack has quit ["Leaving."]
<mfp> mrvn: string does have unsafe_get and _set, are you referring to this? " So most of the time I want unsafe calls and String does not have any." ??
<mfp> there's also Char.unsafe_chr : int -> char fwiw
<mrvn> Indeed it does. Why is that left out of the docs?
<mfp> mrvn: if the extra indirection is OK, you can use an OCaml value pointing to the string residing outside the caml heap, with a finaliser that frees it
<mfp> that way the un-managed string can be GCed
<mrvn> mfp: then I need a C wrapper that follows the indirection
<mfp> then, you get rid of the indirection by doing:
<mfp> with_buffer (fun s -> .... )
<mrvn> which might let the string escape the scope, then it gets freeed and later used
<mfp> which is written in such a way that the wrapper is not GCed before the func is done
<mfp> true, you'd have to be disciplined
<mrvn> can't garanty that in the lib.
<mfp> BUT
<mrvn> Currently I have unsafe_string : buffer -> string
<mfp> nothing
<mfp> what are you writing?
<mrvn> a filesystem + libfuse bindings + lbaio bindings
<flux> mrvn, you could use monads \o/ ?
<mrvn> I actualy have all that already. Just making it nicer and cleaner now so it can be packaged and used by others too.
<mfp> they cannot prevent escape
<mrvn> flux: How does that get around the problem of having a chunk of unmovable memory to read/write data from/to?
<flux> with_buffer (fun () -> get 4 >>= fun ch -> set 3 ch) etc..
<flux> when you don't have any actual handle to the data, you cannot escape it
<mfp> oh
<mfp> but >>= would kill perf
<flux> that might be :)
<mrvn> and how does that access the string if it doesn't have a handle?
<flux> mrvn, it provides generic accessors for any 'buffer' that has been 'with_buffer'ed
<mrvn> that still needs the buffer
<mfp> mrvn: it'd work like the state monad
<mfp> is camlp4 out of the question?
<mrvn> It needs to cache the string behind the buffer somehow and that means its lifetime is different to that of the buffer. Unless it keeps them both.
<mrvn> type buffer = string_freeer_custom_block * string would work at the cost of the extra indirection.
<mrvn> as hidden type so one can't just pick out the string.
<mrvn> abstract I mean
<flux> basically what you can do, is to have a with_buffer -function and prevent escaping by invalidating the buffer object after with_buffer finishes?
<flux> but that requires an extra level of indirection which you don't want?
Submarine has quit ["Leaving"]
<mrvn> that would leave objects around that give errors at runtime.
tvn2009 has quit [Read error: 110 (Connection timed out)]
<flux> yes, but I think that's acceptable..
<mrvn> Really not.
<flux> if it isn't, let the user write the code in Coq :P
<flux> or patch linear typing into ocaml
<mrvn> The above as abstract type manages it without creating broken objects.
<mrvn> The user will only get the abstract type and that holds the custome block and fake string alive. When the abstract type gets freed the custom blocks frees the string.
<flux> that's ok, if it's not a problem that the block has a too long lifetime
onigiri has joined #ocaml
<mrvn> No longer than a plain string would have.
ttamttam has joined #ocaml
<mrvn> (*COcamlunsafe uint8 le 19.49617.43314.843
<mrvn> So C is 31% slower getting a byte.
<mrvn> And safe is 17% slower.
<mfp> mrvn: you didn't unroll the loop, the diff is larger than that
<mrvn> 16bit unsafe is 2% slower than C
ulfdoz has joined #ocaml
<mrvn> Unrolling 8 calls gives 14.257 vs. 14.843
<mrvn> Unrolling 8 calls to C gives 18.713 vs 19.496
<mrvn> Seems to help more with C
thelema has quit [Remote closed the connection]
<mfp> wait a sec
<mfp> you're using a HoF to time that??
<mrvn> HoF?
<mfp> higher-order function
<mrvn> Yeah. That probably kills any unrolling.
<mfp> it might even be doing caml_apply2 for the caml one
<flux> remember to get a baseline with some function equal to nop?
<mfp> and there's no inlining, no out-of-order execution gains
<mrvn> for n = 0 to 10000000; do for i = 0 to 63 do ignore (oget_uint8_le s i); done; done
<mrvn> 5.002s ocaml, 6.722s C
<mfp> still not unrolled :)
<mfp> (fwiw, it was really using call caml_apply3)
<mrvn> 8x unrolled: C 5.606s, ocaml 4.292s
<mrvn> 16bit, 8x unrolled: C 6.652s, ocaml 10.309s
<mrvn> let oget_uint8_le str off = int_of_char (String.unsafe_get str off)
<mrvn> let oget_uint16_be str off = ((oget_uint8_be str off) lsl 8) + oget_uint8_be str (off + 1)
<mfp> sometimes you get speedups by reordering computations a bit
<mfp> like let a = get off in let b = get (off + 1) in a lsl 8 + 1
thelema has joined #ocaml
<mfp> depends on how lucky you are
<mrvn> That is what the compiler is for usualy.
<hyperboreean> if I have a function that should return a socket is it safe to assume that it returns Unix.file_descr ? So I can define it into mli file?
<mfp> + b even
<thelema> optimize the part of your program that takes enough time to be worth optimizing
<mrvn> hyperboreean: what else would a socket be?
<mfp> mrvn: yes, but ocamlopt isn't an optimizing one
<mrvn> thelema: This going to read/write a gigs to terrabytes of data.
albacker has quit ["Leaving"]
<hyperboreean> mrvn: I'm pretty new to ocaml, but thanks, you've answer my question
<mrvn> hyperboreean: Look at the Unix module at the socket functions.
<thelema> mrvn: yes, and you should write your program first, and look at where it's spending its time before writing fragile code to make some tiny part of it faster
<flux> thelema, but maybe it's more fun to make tiny parts faster?-(
<mrvn> thelema: well, the main part is spend in sha1_buffer. But I can't do anything there.
<thelema> mrvn: then you work on the next part.
<mrvn> The other main part is memcpy of string to Aio.buffer which I can get rid of by having nice access functions directly to the buffer.
<thelema> flux: agreed, I do have fun optimizing, and I'm reminding myself not to work hard on something that doesn't matter.
<mrvn> i.e. what we were talking about. :)
<mrvn> It is too bad the code must run on a VIA Eden (32bit single core). I could throw away int32 and stuff the sha1_buffer into worker threads on my 64bit dual core Atom330.
<mrvn> dual core, dual thread even.
ikaros has joined #ocaml
peddie has quit [Remote closed the connection]
peddie has joined #ocaml
_JusSx_ has joined #ocaml
ulfdoz has quit [Remote closed the connection]
ulfdoz has joined #ocaml
julm has quit [Read error: 60 (Operation timed out)]
Submarine has joined #ocaml
julm has joined #ocaml
tvn2009 has joined #ocaml
Submarine_ has joined #ocaml
_JusSx_ has quit ["leaving"]
spicey has joined #ocaml
spicey has left #ocaml []
spicey has joined #ocaml
Submarine has quit [Success]
<spicey> How can I store together in some iterable structure a bunch of objects which have a common parent class, but have additional specific methods added down the hierarchy? A trivial failing example: http://codepad.org/phdz3cxZ
<hcarty> spicey: You need to cast them all to the parent class - http://codepad.org/8uh0N61a
<spicey> thanks!
<BigJ> can anyone help me with the syntax of 2 statements in between my else if and else statement....
ygrek has joined #ocaml
ikaros has quit ["Leave the magic to Houdini"]
Yoric[DT] has joined #ocaml
<BigJ> else if s.size = 0 then
<BigJ> s.seq.(s.size) <- v;
<BigJ> s.size <- s.size + 1;
<BigJ> else s.seq.(s.size) <- v;
<hcarty> BigJ: ";" often (though not always...) breaks a if/else expression
tvn2009 has quit [Read error: 113 (No route to host)]
<hcarty> BigJ: No need to paste here :-)
<BigJ> how can I seperate the 2 statements?
<hcarty> BigJ: So you need to wrap that with ( ... ), begin ... end or use "let () = ... in ..." rather than ";"
<BigJ> ahhh
<hcarty> if ( ... ) else if ( ... ) else ...
<hcarty> BigJ: When in doubt, wrap multi-line expressions in an if/else with () or begin...end
tvn2009 has joined #ocaml
<BigJ> can't get it to work....
Guest27472 has joined #ocaml
<hcarty> BigJ: You still need the ; in there
<hcarty> BigJ:
<BigJ> k thanks
<hcarty> Something like that
<Guest27472> gildor?
Guest27472 has quit ["Java user signed off"]
_JusSx_ has joined #ocaml
sramsay has joined #ocaml
eldragon has joined #ocaml
Associat0r has joined #ocaml
wolfslack has joined #ocaml
<wolfslack> It is possible to use C and C++ libraries in Ocaml without too much hazzle?
<wolfslack> Im deciding what language to learn next at the moment.
<Camarade_Tux> yes it's possible
<Camarade_Tux> there are several programs that can automate the bridge too
<Camarade_Tux> wolfslack: do you have any specific library in mid?
<Camarade_Tux> *mind
<wolfslack> well, im curious about Qt integration and just C, C++ in general. The libraries for these oldies are quite wast :)
ulfdoz has quit [Read error: 110 (Connection timed out)]
<wolfslack> And after learning ML i would like to stay in the environment.
<mrvn> c++ isn't that trivial though with all the classes. Hard to get that to map to ocaml classes sometimes.
<Camarade_Tux> qt in ocaml is not ready unfortunately
<Camarade_Tux> there is at least someone who used ocaml for core code and python for gui
_JusSx__ has joined #ocaml
<wolfslack> Thats one way to enforce MVC i suppose
_JusSx__ has quit [Client Quit]
Alpounet has quit [Remote closed the connection]
_JusSx_ has quit [Read error: 110 (Connection timed out)]
<wolfslack> well ocaml definetly looks slick.
<wolfslack> how does it compile versus SML on Milton ?
<Camarade_Tux> it is :P
<Camarade_Tux> what do you mean? speed of code?
Alpounet has joined #ocaml
<wolfslack> yes
<Camarade_Tux> mlton is probably faster (sml, I don't know but I don't think so) but mlton takes ages to compile even simple programs (that really put me off)
<Camarade_Tux> be warned I don't have much experience with them so I may be wrong
<Camarade_Tux> hahaha, python is slower than javascript-v8 on the great language shootout :)
<wolfslack> wow Oo
<BigJ> for some reason array.sort is sorting my array and gets rid of the last element
<Camarade_Tux> huh ?
<wolfslack> Python is an interesting hybrid, don't think i dare to learn it.
<Camarade_Tux> my number one reason for not learning it is I don't like its syntax (and already have ocaml)
_JusSx_ has joined #ocaml
<wolfslack> Well i might be on the wagon ;)
rwmjones_lptp has joined #ocaml
spicey has quit ["Leaving"]
hto has joined #ocaml
Associat0r has quit [wolfe.freenode.net irc.freenode.net]
eldragon has quit [wolfe.freenode.net irc.freenode.net]
sramsay has quit [wolfe.freenode.net irc.freenode.net]
travisbrady has quit [wolfe.freenode.net irc.freenode.net]
Amorphous has quit [wolfe.freenode.net irc.freenode.net]
mfp has quit [wolfe.freenode.net irc.freenode.net]
Asmadeus has quit [wolfe.freenode.net irc.freenode.net]
flux has quit [wolfe.freenode.net irc.freenode.net]
bohanlon has quit [wolfe.freenode.net irc.freenode.net]
mehdid has quit [wolfe.freenode.net irc.freenode.net]
rwmjones_lptp has quit [wolfe.freenode.net irc.freenode.net]
BigJ2 has quit [wolfe.freenode.net irc.freenode.net]
struktured has quit [wolfe.freenode.net irc.freenode.net]
jknick has quit [wolfe.freenode.net irc.freenode.net]
schme has quit [wolfe.freenode.net irc.freenode.net]
mlh has quit [wolfe.freenode.net irc.freenode.net]
tonyIII__ has quit [wolfe.freenode.net irc.freenode.net]
mbishop has quit [wolfe.freenode.net irc.freenode.net]
Xteven has quit [wolfe.freenode.net irc.freenode.net]
tiz has quit [wolfe.freenode.net irc.freenode.net]
Vital303 has quit [wolfe.freenode.net irc.freenode.net]
ozzloy has quit [wolfe.freenode.net irc.freenode.net]
Pepe_ has quit [wolfe.freenode.net irc.freenode.net]
ygrek has quit [wolfe.freenode.net irc.freenode.net]
Alpounet has quit [wolfe.freenode.net irc.freenode.net]
Submarine_ has quit [wolfe.freenode.net irc.freenode.net]
julm has quit [wolfe.freenode.net irc.freenode.net]
jonafan has quit [wolfe.freenode.net irc.freenode.net]
smimou has quit [wolfe.freenode.net irc.freenode.net]
M| has quit [wolfe.freenode.net irc.freenode.net]
jimmyb2187 has quit [wolfe.freenode.net irc.freenode.net]
ezra has quit [wolfe.freenode.net irc.freenode.net]
Associat0r has joined #ocaml
eldragon has joined #ocaml
sramsay has joined #ocaml
travisbrady has joined #ocaml
Amorphous has joined #ocaml
mfp has joined #ocaml
Asmadeus has joined #ocaml
bohanlon has joined #ocaml
flux has joined #ocaml
rwmjones_lptp has joined #ocaml
Alpounet has joined #ocaml
ygrek has joined #ocaml
Submarine_ has joined #ocaml
julm has joined #ocaml
jonafan has joined #ocaml
Vital303 has joined #ocaml
BigJ2 has joined #ocaml
smimou has joined #ocaml
mehdid has joined #ocaml
ezra has joined #ocaml
M| has joined #ocaml
struktured has joined #ocaml
Xteven has joined #ocaml
Pepe_ has joined #ocaml
mbishop has joined #ocaml
jimmyb2187 has joined #ocaml
mlh has joined #ocaml
schme has joined #ocaml
jknick has joined #ocaml
ozzloy has joined #ocaml
tonyIII__ has joined #ocaml
tiz has joined #ocaml
ttamttam has quit ["Leaving."]
<wolfslack> whats going on in this channel
ygrek has quit [Remote closed the connection]
<Camarade_Tux> netsplit :)
<Camarade_Tux> happened everywhere on the freenode channel, a connectivity problem at the server level
<wolfslack> aha
ztfw has quit [Remote closed the connection]
<Camarade_Tux> does anyone have a Mastermind solver? mldonkey has "reliable sources" which pinpoints bad sources which corrupted your download (since several sources contribute to a single transfer)
slash_ has joined #ocaml
<BigJ> is there anyway to tell the Array.sort function to only sort a certain # of elements in an array?
<Camarade_Tux> no, it wouldn't be a sort ^^
<Camarade_Tux> BigJ: why?
<wolfslack> The list wouldnt be sorted after.
<wolfslack> why don't just cut out a piece of the array, sort it and glue it back on.
<BigJ> wolfslack, it might be easier to use a for loop to sort to the length I want...
<mrvn> Camarade_Tux: I do
<Camarade_Tux> mrvn: will you mind sharing it? (but not today, I'm going to bed now ;) )
<Camarade_Tux> BigJ: why do you want to sort only parts of the array? (not saying you don't have a good reason to)
<BigJ> Camarade_Tux, because I initial define an array to have a max_length = 100; I think have a function that adds individual elements 1 at a time and I track the length of the array by a seperate int value
<mrvn> Camarade_Tux: http://paste.debian.net/50314/
<BigJ> so I have all values in the array initialized to 0
<mrvn> initialize them to max_int
<BigJ> and I only want to sort the number of elements I have placed into the array and then place them in order from smallest to largest
<wolfslack> BigJ well, if you glue off and on you can use any algorithm you want. Loops make me thing of complete partial reinplementations.
<wolfslack> things = think
<mrvn> Camarade_Tux: Usage is "./Mastermind abcd" where abcd are the possible colors. The width is hardcoded.
rwmjones_lptp has quit ["This computer has gone to sleep"]
<Camarade_Tux> BigJ: seems a very inefficient way to create your arrays
* mrvn likes merge sort
<BigJ> Camarade_Tux, I agree
<BigJ> but it is for the purposes of an assignment
<mrvn> BigJ: and initialzing with max_int and just sort them all isn't an option?
<wolfslack> first you sort it with bubble sort, then use iteration to access elements.
<mrvn> or are you supposed to implement your own sort?
<mrvn> wolfslack: I prefer spaghetti sort.
<wolfslack> everytime you insert a new element, just run bubble sort again. And whoila. A well-maitained sorted array.
<Camarade_Tux> mrvn: the logic in a mastermind solver helps find "bad" entries among several ones with only knowing the global effect
<BigJ> I can sort in any manner
<mrvn> Camarade_Tux: logic? I just do exhaustive search.
<Camarade_Tux> mrvn: I'd like to have that for my browser :) (I'm using a C library)
<Camarade_Tux> mrvn: argh :P
<wolfslack> Blindsort?
<Camarade_Tux> mrvn: i'll have to check anyway, thanks :)
* Camarade_Tux needs to go to bed now
<Camarade_Tux> BigJ: hmmm, that's weird
<Camarade_Tux> BigJ: but Array.sort is probably bad for your thing, a bubble sort sounds better there
* Camarade_Tux poofs
<mrvn> Camarade_Tux: I generate all possible combinations. Then I find the combination so that no matter what the answere is I'm left with the least number of combinations and I print that as guess.
<mrvn> Input black and white pins, filter only combinations matching that b/w count and repeat.
<mrvn> Camarade_Tux: How else do you want to solve it?
tmaedaZ is now known as tmaeda
tmaeda is now known as tmaedaZ
tmaedaZ is now known as tmaeda
<Camarade_Tux> mrvn: I think that fits what I need
<Camarade_Tux> mrvn: as for how else, can I answer on tomorrow after sleeping? :D
<mrvn> Camarade_Tux: Mine takes |colors|^holes^2 time and |colors|^holes space.
ikaros has joined #ocaml
julm has quit ["leaving"]
ikaros has quit ["Leave the magic to Houdini"]
<travisbrady> anyone know of online docs anywhere for Jane Street's Core?