gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.0 http://bit.ly/aNZBUp
infoe2 has joined #ocaml
banisterfiend has quit [Ping timeout: 240 seconds]
infoe1 has quit [Ping timeout: 265 seconds]
mnabil_ has joined #ocaml
banisterfiend has joined #ocaml
infoe2 is now known as infoe
jonrafkind has quit [Ping timeout: 264 seconds]
rwmjones has quit [Ping timeout: 272 seconds]
rwmjones has joined #ocaml
rwmjones has quit [Read error: Operation timed out]
rwmjones has joined #ocaml
alexyk has joined #ocaml
<alexyk> is there a predefined compare descending, to avoid typing (fun x y -> compare y x) every time I need it?
<hcarty> alexyk: Not in the standard library. You could just define compare_desc once and reuse it...
<alexyk> how about a predefined swap x y -> y x? swap |> compare
<alexyk> is there a swap?
<alexyk> (I'm in Batteries)
<hcarty> Is there a way to pass C compiler flags to the oasis build process? Specifically for telling Lwt's build system where to find libev.
<hcarty> alexyk: I think so
<hcarty> Probably in the main Batteries module
<alexyk> alas, that swap is about refs, in BatRef
<hcarty> There is a an equivalent to the swap function you want
<hcarty> I don't remember the name
<alexyk> yeah... guessing doesn't get it yet: http://thelema.github.com/batteries-included/hdoc/index_values.html
<hcarty> alexyk: flip maube?
<hcarty> maybe that is
<hcarty> val flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c
<alexyk> yep, Array.sort (flip compare) is descending
<alexyk> hcarty: BTW, is Lwt real parallelism or preemptive?
<hcarty> alexyk: Neither, it is for non-parallel concurrent programming
<hcarty> alexyk: That said, I've only really used it for it's super-spiffy custom toplevel :-)
<alexyk> hcarty: so 1 effective thread running at a time?
myu2 has quit [Remote host closed the connection]
<hcarty> Yes, only one thread at at time, and only one "real" thread
<hcarty> ocamlp3l, preludeml/fork, jocaml, ocamlnet and ocamlmpi and the main options for true parallelism in OCaml
<alexyk> ok
<thelema> hcarty: s/and/are/
<hcarty> thelema: Yes, thanks
<mrvn> alexyk: the ocaml runtime can only run one thread at a time with ocaml code.
<alexyk> Dr. Harrop will not stop preferring F# to OCaml until we get it right :)
<mrvn> alexyk: f# has a stop-the-world GC or not?
<alexyk> mrvn: AFAIU F# relies on the .Net GC which is concurrent
<alexyk> MSFT has powerful parallel collections and algorithms libraries as well
<mrvn> alexyk: no. the .net GC is crap and a stop-the-world one.
<mrvn> afaik
<alexyk> mrvn: uh, ok
<thelema> mrvn: the .Net GC can be run in either concurrent or stop the world mode.
<thelema> the mono gc stops the world
<mrvn> thelema: oh, that can be. I only now it from the mono side.
<thelema> mrvn: yes, mono's GC is... crap
<mrvn> why does mono have a crappy GC if NET has a good one?
mfp has quit [Ping timeout: 240 seconds]
mfp has joined #ocaml
<alexyk> mrvn: GC is expensive to develop, Sun even thought of charging for its latest Java one...
<thelema> GC is hard. We should be very thankful for the good GC we have in ocaml.
<thelema> an ancestor of ocaml had a concurrent GC, that was even proven correct. But it was still too hard to maintain.
banisterfiend has quit [Ping timeout: 260 seconds]
<alexyk> is there a predefined zip: ('a*'b) list -> 'a list * 'b list ?
<alexyk> unzip I mean
banisterfiend has joined #ocaml
<mrvn> # let unzip l = List.fold_left (fun (xs, ys) (x, y) -> (x::xs, y::ys)) ([], []) l;;
<mrvn> val unzip : ('a * 'b) list -> 'a list * 'b list = <fun>
<mrvn> val split : ('a * 'b) list -> 'a list * 'b list
<mrvn> Transform a list of pairs into a pair of lists: split [(a1,b1); ...; (an,bn)] is ([a1; ...; an], [b1; ...; bn]). Not tail-recursive.
<alexyk> kk
<mrvn> I think my unzip lacks a List.rev
<mrvn> # let unzip l = List.fold_left (fun (xs, ys) (x, y) -> (x::xs, y::ys)) ([], []) (List.rev l);;
<mrvn> val unzip : ('a * 'b) list -> 'a list * 'b list = <fun>
<mrvn> # unzip [(1,2);(3,4);(5,6)];;
<mrvn> - : int list * int list = ([1; 3; 5], [2; 4; 6])
<thelema> BatList.split
<alexyk> thelema: why isn't there a BatArray.split?
<thelema> array?
<thelema> too easy to write, I guess
<mrvn> split an array of pairs into a pair of arrays?
<alexyk> thelema: well, it would preallocate the arrays, so not so compact
<alexyk> mrvn: yeah, we know the length, so we do two creates and one iter with <-
<alexyk> I'd take that over predefined list split
<thelema> let array_split a = Array.init (len a) (Array.get a |- fst), Array.init (len a) (Array.get a |- snd)
<mrvn> alexyk: or 2 inits
<alexyk> thelema: wouldn't one init and iter be faster?
<alexyk> we do two passes here
<thelema> alexyk: Array.create does one pass
<alexyk> ok
<alexyk> so two passes either way
<thelema> yes, I guess you might save one pass over the input with an init and an iter
<thelema> but you pay an extra pass over output, and make the cache prefetch logic in the cpu unhappy
<alexyk> yep
Amorphous has quit [Ping timeout: 272 seconds]
<alexyk> what's the syntax for updating multiple fields in a record? one: {x with field=v}
<mrvn> {x with field=v; field2=v; ... }
<alexyk> kk, thx!
alexyk has quit [Quit: alexyk]
Amorphous has joined #ocaml
banisterfiend has quit [Ping timeout: 240 seconds]
banisterfiend`` has joined #ocaml
drunK has quit [Remote host closed the connection]
banisterfiend`` has quit [Ping timeout: 276 seconds]
alexyk has joined #ocaml
banisterfiend has joined #ocaml
myu2 has joined #ocaml
smerz has quit [Quit: Ex-Chat]
ezyang has quit [Ping timeout: 240 seconds]
ulfdoz has joined #ocaml
boscop has joined #ocaml
boscop has quit [Ping timeout: 240 seconds]
myu2 has quit [Remote host closed the connection]
myu2 has joined #ocaml
jonrafkind has joined #ocaml
alexyk has quit [Quit: alexyk]
ulfdoz has quit [Ping timeout: 255 seconds]
rien_home has quit [Ping timeout: 240 seconds]
rien_home has joined #ocaml
lamawithonel has quit [Remote host closed the connection]
jonrafkind has quit [Ping timeout: 260 seconds]
ygrek has joined #ocaml
banisterfiend`` has joined #ocaml
banisterfiend has quit [Ping timeout: 265 seconds]
edwin has joined #ocaml
eye-scuzzy has quit [Read error: Operation timed out]
sgnb has quit [Read error: Operation timed out]
almaisan-away is now known as al-maisan
sgnb has joined #ocaml
eye-scuzzy has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
myu2 has quit [Remote host closed the connection]
ikaros has joined #ocaml
ttamttam has joined #ocaml
ttamttam has left #ocaml []
Yoric has joined #ocaml
hto has quit [Read error: Connection reset by peer]
hto has joined #ocaml
avsm has joined #ocaml
_andre has joined #ocaml
Yoric has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
ygrek has joined #ocaml
yurug has joined #ocaml
LeNsTR has joined #ocaml
LeNsTR has quit [Changing host]
LeNsTR has joined #ocaml
hto has quit [Read error: Connection reset by peer]
hto has joined #ocaml
drunK has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
al-maisan is now known as almaisan-away
avsm2 has quit [Quit: avsm2]
avsm has quit [Read error: Connection reset by peer]
avsm has joined #ocaml
myu2 has joined #ocaml
mnabil_ has quit [Ping timeout: 240 seconds]
mnabil_ has joined #ocaml
LeNsTR has quit [Read error: Connection reset by peer]
mrvn has quit [Ping timeout: 240 seconds]
mrvn has joined #ocaml
Snark has joined #ocaml
sgnb has quit [Read error: Operation timed out]
sgnb has joined #ocaml
eye-scuzzy has quit [Ping timeout: 260 seconds]
eye-scuzzy has joined #ocaml
Modius has quit [Quit: "Object-oriented design" is an oxymoron]
humasect has joined #ocaml
almaisan-away is now known as al-maisan
Yoric has quit [Quit: Yoric]
Yoric has joined #ocaml
fraggle_laptop has joined #ocaml
WonTu has joined #ocaml
WonTu has left #ocaml []
boscop has joined #ocaml
mikemc has quit [Remote host closed the connection]
rien_home is now known as rien_
munga has joined #ocaml
munga has quit [Client Quit]
mikemc has joined #ocaml
banisterfiend`` has quit [Ping timeout: 250 seconds]
<hcarty> gildor: Is there a consistent way to provide extra flags to the C compiler for a project using oasis? An equivalent to CFLAGS, for example.
<hcarty> diml: You may be able to help. I would like to be able to specify the libev include and lib locations when building/configuring Lwt 2.2.0
<hcarty> diml: Is there a way to do this with Lwt's build system?
humasect has left #ocaml []
<diml> hcarty: you can use the environment variables C_INCLUDE_PATH and LIBRARY_PATH
<hcarty> diml: Ok, thank you! I'll give it a try.
<hcarty> diml: Thank you, defining/updating C_INCLUDE_PATH and LIBRARY_PATH appropriately does exactly what I need
<edwin> wouldn't CCOpt work too?
<hcarty> edwin: Would that be set as an environment variable, or would I have to edit the _oasis file?
<edwin> hcarty: field in _oasis
<edwin> ah wait, you mean for C sources specified in _oasis?
<edwin> or for ocamlopt?
<hcarty> edwin: C sources
<hcarty> For a C library which is not under /usr or /usr/local
<edwin> hcarty: ccopt seems to work for that too: ocamlfind ocamlc -ccopt -DFOO -c foo2.c
<edwin> thats how it gets compiled if I specify CCOpt: -DFOO
<ygrek> gildor promised support for pkg-config + manual specification of include and lib path via configure args in oasis 0.3.0
<edwin> checking for a C lib in configure would be good, yes
<edwin> problem is with CCOpt you'll get the include path set when you compile ML files too, where they are not needed
<edwin> and you'll need to use CCLib for lib paths
<hcarty> ygrek: Ok, that's good to know. I thought I had heard something about that.
<hcarty> diml: If I resize a window with an Lwt toplevel running in it, the toplevel appears to freeze
Yoric has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
Yoric has quit [Client Quit]
<hcarty> diml: I may have spoken too soon. I had a .ocamlinit file. If I remove that, then it does not seem to freeze on a resize
<thelema> hcarty: what's in your ocamlinit (other than batteries?)
<hcarty> thelema: #thread and #require "batteries"
<thelema> doh
<hcarty> thelema: But I also turn off/on Sys.interactive
<hcarty> Let me try removing that
<diml> hcarty: note that you must not have '#use "topfind"' in you ocamlinit if you use the lwt toplevel
ikaros has joined #ocaml
<diml> findlib is already integreated and adding this line will cause unix.cma to be reloaded
<hcarty> diml: That seems to be the problem. I removed that line and now everything seems to work.
<hcarty> There printing of the completion bar gets mixed up a little bit during a window resize
<hcarty> But that's a small price to pay for such a wonderful tool :-)
<hcarty> diml: Thank you for the lwt toplevel. It's very nice.
<gildor> ygrek, hcarty: more than a promise, I'll do it ;-)
<gildor> ygrek, hcarty: it is too much needed to be ignored
jm_ocaml has joined #ocaml
__marius__ has quit [Remote host closed the connection]
ygrek has quit [Ping timeout: 240 seconds]
eye-scuzzy has quit [Quit: leaving]
eye-scuzzy has joined #ocaml
notk0 has joined #ocaml
<notk0> hello, what is the command to find the location of the ocaml library?
<hcarty> notk0: The standard library? "ocamlc -where"
<notk0> hcarty, thank you
notk0 has quit [Quit: bye bye]
alexyk has joined #ocaml
alexyk has quit [Read error: Connection reset by peer]
infoe has quit [Read error: Connection reset by peer]
infoe has joined #ocaml
mnabil_ has quit [Ping timeout: 240 seconds]
alexyk has joined #ocaml
alexyk has quit [Read error: Connection reset by peer]
al-maisan is now known as almaisan-away
almaisan-away is now known as al-maisan
<edwin> gildor: thanks for approving proj. where do I upload my ssh key though, or how can I push something to the git repo?
mnabil_ has joined #ocaml
al-maisan is now known as almaisan-away
almaisan-away has quit [Quit: Coyote finally caught me]
almaisan-away has joined #ocaml
almaisan-away is now known as al-maisan
al-maisan is now known as almaisan-away
alexyk has joined #ocaml
alexyk has quit [Read error: Connection reset by peer]
<edwin> gildor: nevermind, found the page for ssh keys, interesting that there are no links to it from my account page
<hcarty> edwin: It's probably worth submitting a bug report/feature request
fraggle_laptop has quit [Remote host closed the connection]
<gildor> hcarty, edwin: yes but take into account that patches are also welcome
* gildor needs help, esp. on PHP stuff
alexyk has joined #ocaml
<edwin> opened as feature request
<edwin> gildor: is it easy to setup an instance of fusionforge on my own box?
<gildor> edwin: you can start from a prebuilt vmware instance
<edwin> gildor: if it runs with KVM, sure, got a link?
<edwin> or I can setup something in a chroot
<gildor> chroot is not a good idea because the system needs several daemons
<edwin> ok, VM it is then
<gildor> but I would get in touch with adrien about that
<gildor> he has already done some modification for fusionforge, using KVM/vmware (not sure)
<gildor> ask adrien, how he does.
<gildor> I can also give you access to some files on test.ocamlcore.org:4080
<gildor> but it will be more limited
<edwin> and how can I use your latest sourcecode?
<gildor> clone this git repository, it contains the fusionforge software
<edwin> fatal: http://git.ocamlcore.org/siteadmin/fusionforge.git/info/refs not found: did you run git update-server-info on the server
<gildor> edwin: but basically, if you do the change against fusionforge, I will get it
<gildor> missing hook
<edwin> can I clone via git://?
<edwin> or can you run update-server-info?
alexyk has quit [Read error: Connection reset by peer]
<gildor> edwin: I fix the missing update-server-info
<gildor> try again
<edwin> gildor: thanks, its cloning now
<gildor> edwin: the link is at the bottom of the page of My page -> Account Maintenance
<edwin> gildor: there is actually code there to show the ssh keys link
avsm has quit [Ping timeout: 260 seconds]
<gildor> it is called "Edit keys "
<edwin> not on my user page
<edwin> if (($u->getUnixStatus() == 'A') && (forge_get_config('use_shell'))) {
infoe has quit [Ping timeout: 240 seconds]
<edwin> maybe my status is wrong?
Yoric has joined #ocaml
<gildor> nope, you are active
<gildor> on the web page
<edwin> did my user get its shell activated recently?
<edwin> maybe its that cronjob that syncs keys didn't run yet, so something is wrong with my status
avsm has joined #ocaml
<gildor> edwin: you unix status is N
<edwin> am I member of any groups?
<edwin> it will only activate if I am member of at least one group
<gildor> yes, of ocaml-judy
<edwin> looks like a bug in project approval then hmm
<gildor> no, I don't think so
<gildor> did you receive any emails that ask for confirmation ?
<edwin> nope
<edwin> 1 mail for new project approved
<edwin> 1 for new list
<edwin> 1 for list password
<edwin> was I supposed to receive another?
<gildor> when you registered your user, you should have receive a confirmation email
<edwin> ah there yes
<edwin> I confirmed my account with that link
<edwin> but it said nothing about shell
<gildor> I know
<edwin> I registered in december though
<edwin> when did you roll out new forge?
<gildor> in december
<edwin> I registered 30th
<edwin> I guess I was on the new forge already then
<gildor> yes you was
<gildor> have you ever try to login ?
<edwin> sure, I submitted all those bugs for you ;)
<gildor> to ssh-login
<edwin> ah no
<gildor> try once
<gildor> (you will fail)
<edwin> permission denied
<gildor> don't try twice
<edwin> I tried logging in to ssh.forge.ocamlcore.org and that failed
<edwin> then I uploaded my key
<edwin> (when I found the link to the editsshkeys.php)
<edwin> I think I need to wait an hour or two for the keys to get synced though
<edwin> but I don't see what that has to do with the edit keys being shown or not on the accounts page ...
<gildor> edwin: I run out of time, I need to get back home
<gildor> edwin: basically, some people registered before you and have an active unix status
<edwin> gildor: I'll experiment with that forge VM
<gildor> edwin: and some people after you as well
<edwin> see if I can figure out whats wrong
<gildor> edwin: if you can figure out which job update TABLE users COL unix_status
<gildor> which cronjob
<gildor> we will have half the answer
<gildor> the other guy that have a valid unix account, didn't my help to get here, so I think it is probably just a matter of time
<gildor> but it is better to know why, right now
<gildor> gtg
<edwin> k
Yoric has quit [Quit: Yoric]
avsm has quit [Quit: Leaving.]
jonrafkind has joined #ocaml
myu2 has quit [Remote host closed the connection]
_andre has quit [Quit: *puff*]
alexyk has joined #ocaml
<alexyk> I'm wrapping a bunch of .cmo files into a lib.cma for easier loading into repl. Now I added a line, include Binary_graph, to common.ml, which I open in repl, and now I get an error even at the attempt to load lib.cma! http://paste.pocoo.org/show/316730/ -- why can this cappen?
roconnor has joined #ocaml
<hcarty> alexyk: Try putting binary_graph.cmo before common.cmo in the lib: line
<julm> you give binary_graph after common
<roconnor> can modules contain functors?
<hcarty> The order of files matters for OCaml
<hcarty> roconnor: Yes
<hcarty> roconnor: See Map.Make in the stdlib for an example
<roconnor> so I can have a functor producing a module that conatins another functor?
<hcarty> roconnor: Yes
<hcarty> roconnor: Or a functor which takes multiple modules as arguments
<roconnor> interesting
<thelema> alexyk: umm, don't you need ocamlmklib to make a .cma?
<alexyk> yep, now works. I was sure I was trying different orders. thelema: this actually works :)
<alexyk> I can enjoy the .cma in repl
<hcarty> thelema: I think think ocamlmklib is used?
<thelema> alexyk: are you really making a .cma or really a .cmo with the wrong extension
<alexyk> thelema: I got this line off this very forum :) So I'm not sure...
<alexyk> thelema: what would real .cma have differently?
<hcarty> thelema: Sorry - I apparently can't read or type. I misread your message, then mistyped my response...
<alexyk> hcarty: sounds like a great excuse for every situation! :)
<alexyk> another good one, "I was drunk" :)
<hcarty> alexyk: thelema has corrected a few typos for me recently. I don't want to become dependent :-)
<hcarty> thelema: According to the ocamlc documentation, it looks like you can build a cma without ocamlmklib. I don't know what the differences are in output between the two though.
Edward__ has joined #ocaml
<adrien> "19:28 + raela : 2. to get the flag, you'd add for example 0x0010 + 0x0004 + 0x0001 = 16 + 8 + 1 = 27"
<adrien> 0x10 + 0x04 + 0x01 = 27
<thelema> hcarty: okay then. I guess it is possible to create simple .cma files without ocamlmklib
<julm> of course
<thelema> on the other hand, that code makes me weep in terms of how much work simple things are.
alexyk has quit [Quit: alexyk]
<edwin> gildor: new users are created with Unix account: N, however if I click on [update] as admin (after they registered a project) it changes instantly to 'A'
<edwin> gildor: didn't manage to find a cronjob that does that
ygrek has joined #ocaml
alexyk has joined #ocaml
alexyk has quit [Client Quit]
jonrafkind has quit [Ping timeout: 264 seconds]
alexyk has joined #ocaml
<edwin> gildor: AFAICT its supposed to get activated when project group is created
<edwin> but its not
alexyk has quit [Client Quit]
metasyntax` has quit [Quit: Be seeing you.]
<thelema> any help with a wierd 'Not_found' coming from pervasives when I move a binary from one computer to another?
<adrien> well, backtrace?
<thelema> Raised at file "pervasives.ml", line 280, characters 20-46
lamawithonel has joined #ocaml
<thelema> ocaml 3.11.2, if it matters
<adrien> what's the minimal testcase? empty sourcefile?
<thelema> well, batteries is involved and bitsrring
<thelema> *bitstring
<thelema> gimme a bit to minimize
<adrien> could that be camomile? I can't remember the exact issue
<thelema> huh, apparently not either of those libraries, a simpler executable built with both seems to work
<thelema> no, I already had and resolved the camomile issue by setting the environment var
<adrien> it looks like it's in open_in_gen (grabbed 3.11.2's pervasives.ml)
<thelema> yes, that's pretty clearly not it.
<thelema> especially as that line is an external, and I can't see any way for it to raise Not_found
<thelema> more likely it's the wrong location, as my native code tends to report on backtraces
Snark has quit [Quit: Ex-Chat]
<thelema> hmm, doesn't even get to the entrypoint of my main module
* thelema is learning about gdb
Yoric has joined #ocaml
<thelema> hmm, maybe ocamlviz (which is linked in, but I'm not even using) is causing a problem...
<adrien> you tried gdb?
<thelema> yes, I can set breakpoints, but I can't find one it actually reaches
<thelema> I guess I could set a breakpoint on pervasives...
<thelema> yay, it does reach pervasives...
<thelema> caml_program() seems to raise the exception...
<adrien> tried getting a backtrace?
<adrien> just "bt", nothing more
<thelema> or not...
<thelema> when do you want the backtrace?
<adrien> I'd expect: "gdb ./a.out" "run" "bt" to show what's going on
<thelema> "run" completes properly, with the ocaml runtime providing a backtrace
<thelema> and the executable exiting
<adrien> ah, right, had forgotten about that
<thelema> here's the last backtrace, one step before it quits:
<thelema> #0 0x0000000000443269 in caml_program ()
<thelema> #1 0x000000000031ae4b in ?? ()
<thelema> #2 0x000000000058a16a in caml_start_program ()
<thelema> #3 0x0000000000000000 in ?? ()
<adrien> ocamldebug? strace?
<thelema> I thought ocamldebug was only for bytecode
<edwin> gildor: in activateUsers(), Group->getUsers() /usr/share/gforge/common/include/Group.class.php returns an empty array for newly created group's members
<thelema> sh, strace has helped, it quits right after failing to load /usr/share/camomile/database/age.mar
<adrien> yeah, I forgot to ask if you had tried in bytecode: iirc the backtraces are sometimes better
<thelema> s/sh/ah/
<thelema> yes, they usually are. but my build system is hard to switch to bytecode
<hcarty> thelema: I had a heck of a time getting the linking correct for the OCaml portion of PLplot, from the confines of CMake. The documentation seemed clear as mud at that time.
<hcarty> OCamlMakefile and ocamlbuild (and now/soon oasis) help smooth over the difficulty, but I still don't think I have a solid handle on the details of OCaml compilation + linking
ezyang has joined #ocaml
<thelema> I'm linking in some C, otherwise I'd be happy with ocamlbuild.
<ezyang> Hello all, is there a pre-canned O(n) find the median of an unsorted array function I can use?
<thelema> ezyang: no
<ezyang> blah
<hcarty> ezyang: GSL maybe?
<hcarty> If GSL + ocamlgsl is pre-canned enough
<adrien> thelema: well, you can use ocamlbuild but it has a serious limitation with headers (.h files are not copied to _build and are therefore not found during calls to gcc: you can 1- use -I to the original folder, 2- patch ocamlbuild but that won't always work [only mostly])
<hcarty> thelema: Yes... every time I have to bring C in, it's a struggle to decide between the OCamlMakefile and ocamlbuild
<adrien> also, oasis should help here (it should workaround the issue), need to try it again, in a bunch of days I hope
<ezyang> hm, gsl seems a bit heavyweight
<thelema> yay, copying the camomile data files over fixed things... (apparently I had old camomile installed on the other machine)
fraggle_ has quit [Ping timeout: 276 seconds]
fraggle_ has joined #ocaml
alexyk has joined #ocaml
<ezyang> Looking for naming help. I have two constructors for a data structure: one where you specify the height and width, and one where you specify what probabalistic properties the structure should have and it calculates the height and width for you.
<ezyang> Right now they are respectively make_raw and make, but those feel clunky.
<hcarty> ezyang: It is potentially less checked at compile-time, but you could combine them in to one function and use optional arguments
<ezyang> hcarty: Hm, I guess I could
<ezyang> Though I think two separate functions makes a lot more sense.
<hcarty> Combining is certainly not best for everything
<ezyang> because make is literally "calculate height and width, and then call make_raw"
<jm_ocaml> Why do you feel that the make and make_row are not good names? Also, what is your data structure representing?
mnabil_ has quit [Read error: Connection reset by peer]
<ezyang> Ah, maybe they are fine names :-) The structure being created is a count min sketch.
<thelema> separate functions makes more sense, from what I recall. It's common to see "_int" for the internal (not user-friendly) version of a function
<ezyang> ok, that works well
<ezyang> has a nice pun too (make : float -> float -> sketch and make_int : int -> int -> sketch :-)
<thelema> :)
<ezyang> Heh, it would be cool if ocamldoc could generate mathematical equations from LaTeX in its HTML output
<thelema> yup, that would be nice. iirc, this was difficult to do back when ocamldoc was written. Now that it's easier... maybe some can patch ocamldoc
<jm_ocaml> I agree! (Well, I'd be more interested in something similar to .lhs for ocaml. Closest I could find is ocamlweb which isn't nearly as nice.)
edwin has quit [Remote host closed the connection]
Yoric has quit [Quit: Yoric]
<ezyang> Can I do an internal link {!foo} inside a module without getting full quantification?
vk0 has quit [Ping timeout: 255 seconds]
tautologico has joined #ocaml
vk0 has joined #ocaml
<thelema> ezyang: {!foo}? a pointer to a record? or is that haskell syntax?
<thelema> s/pointer/reference/
<ezyang> as in, ocamldoc
<ezyang> I want to refer to another function and make it generate a hyperlink
BMeph has left #ocaml []
ygrek has quit [Ping timeout: 240 seconds]
<hcarty> ezyang: What do you mean by full quantification?
<ezyang> {!foo} renders as Modulename.foo
<jm_ocaml> Maybe the -hide list,of,module,name is what you want?
<jm_ocaml> *option
<adrien> oh, new Core is packaged with oasis =)
alexyk has quit [Quit: alexyk]
fraggle_ has quit [Quit: -ENOBRAIN]
fraggle_ has joined #ocaml
alexyk has joined #ocaml
boscop has quit [Ping timeout: 240 seconds]
alexyk has quit [Quit: alexyk]
Edward__ has quit []
<ezyang> I need to implement the dot product of two arrays. Should I do it imperatively or functionally...
<mrvn> yes
<ezyang> "ha!"
<ezyang> the way I'd do it in Haskell is sum (zipWith (*) a b)
<ezyang> but I don't have any of those constructs :-/
<jm_ocaml> Then write them!
<mrvn> That would create a temporary array.
<ezyang> yeah, in OCaml it would do that.
<mrvn> If you do it imperatively then you need a reference for the sum. You have to be carefull with them so they get unpoxed properly.
<ezyang> OCaml is making me think too much about low level details :-(
jm_ocaml has quit [Remote host closed the connection]
<ezyang> here is one try: http://pastebin.com/YX7NFM7m
<mrvn> Array.fold_left ( + ) 0 (Array.init (Array.length a) (fun i -> a.(i) * b.(i)))
<ezyang> Doesn't that do a temporary array too?
<mrvn> yes. that is your zipWith
<ezyang> I think Haskell manages to fuse away all of the structures...
<mrvn> I would do it recursively
* ezyang goes and checks
<ezyang> recursive iterative style, you mean?
<ezyang> because otherwise you'd use lots of stack
<tautologico> GHC can do fusion in some cases
<tautologico> it's not intrinsic to the language, but GHC does support fusion
<mrvn> let len = Array.length a in let rec loop acc = function i when i = len -> acc | i -> loop (acc + a.(i) * b.(i)) (i + 1) in loop 0 0
<mrvn> let rec loop acc = function -1 -> acc | i -> loop (acc + a.(i) * b.(i)) (i - 1) in loop 0 (Array.length a - 1) if you find that more readable.
<mrvn> or let len = Array.length a in let rec loop acc i = if i = len then acc else loop (acc + a.(i) * b.(i)) (i + 1) in loop 0 0
<mrvn> Check Batteries if they have functions acting on 2 arrays like the List module has.
ikaros has quit [Quit: Leave the magic to Houdini]
alexyk has joined #ocaml