<wchicken2>
what is the most compact way to do a cumulative sum?
<wchicken2>
say I have [| 0;1;2;3 |]
myu2 has joined #ocaml
<wchicken2>
I want to get [| 0;1;3;6 |]
<wchicken2>
I could hack up some iterative solution but I feel like I'm doing it "the wrong way"
myu2_ has quit [Ping timeout: 252 seconds]
<thelema>
wchicken2: if you just want to get this done, use Batteries' List.sum
<thelema>
If you want to understand how to do things like this, a good start would be (Array.fold_left (fun acc x -> acc + x) 0 [|0;1;3;6|])
<wchicken2>
the problem is I don't want a final sum -- I want a running sum
<thelema>
err, not a list. and batteries doesn't provide an Array.sum, although I think we provide Array.reduce
<thelema>
wchicken2: oh, okay
<wchicken2>
I could have the fold continually append to a list or keep poking elements into a new array but that feels weird
<thelema>
If you want to understand how to do things like this, a good start would be (Array.fold_left (fun (cur,acc) x -> let s = cur + x in s, s::acc) (0,[]) [|0;1;3;6|])
<thelema>
(you'll still need to modify your findlib.conf to use these new packages)
<thelema>
now I just need a good URI to host it from (like cpanmin.us)
<thelema>
lol, cpanmin.us redirects to github
myu2 has quit [Remote host closed the connection]
myu2 has joined #ocaml
enthymeme has quit [Quit: rcirc on GNU Emacs 23.1.1]
lopex has quit []
myu2 has quit [Remote host closed the connection]
tauntaun has quit [Quit: Ex-Chat]
<wchicken2>
thanks again thelema! gotta bounce
wchicken2 has quit [Quit: leaving]
<thelema>
please test and send feedback (as well as recommended packages to put on server) for odb: https://github.com/thelema/odb
eye-scuzzy has quit [Quit: leaving]
Oejet has quit [Ping timeout: 264 seconds]
eye-scuzzy has joined #ocaml
enthymeme has joined #ocaml
arubin has joined #ocaml
lamawithonel has joined #ocaml
myu2 has joined #ocaml
lamawithonel has quit [Ping timeout: 264 seconds]
ulfdoz has quit [Ping timeout: 250 seconds]
patronus has joined #ocaml
patronus_ has quit [Read error: Connection reset by peer]
bitbckt has quit [Remote host closed the connection]
bitbckt has joined #ocaml
bitbckt has quit [Changing host]
bitbckt has joined #ocaml
CoryDambach has quit [Ping timeout: 240 seconds]
arubin has quit [Quit: arubin]
CoryDambach has joined #ocaml
myu2 has quit [Remote host closed the connection]
myu2 has joined #ocaml
enthymeme has quit [Quit: rcirc on GNU Emacs 23.1.1]
hto has quit [Quit: Lost terminal]
hto has joined #ocaml
philtor has quit [Ping timeout: 240 seconds]
Yoric has joined #ocaml
hto has quit [Quit: Lost terminal]
hto has joined #ocaml
Cyanure has joined #ocaml
vivanov has quit [Ping timeout: 240 seconds]
ygrek has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
Yoric has quit [Quit: Yoric]
ikaros has joined #ocaml
larhat has joined #ocaml
jdavis has quit [Ping timeout: 264 seconds]
vivanov has joined #ocaml
jdavis has joined #ocaml
vivanov has quit [Ping timeout: 276 seconds]
vivanov has joined #ocaml
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
sepp2k has joined #ocaml
Oejet has joined #ocaml
mnabil has joined #ocaml
Oejet has quit [Ping timeout: 276 seconds]
mikemc_home has quit [Quit: Leaving]
mikemc_home has joined #ocaml
myu2 has quit [Remote host closed the connection]
myu2 has joined #ocaml
olegfink has joined #ocaml
Yoric has joined #ocaml
ftrvxmtrx has joined #ocaml
<kaustuv>
thelema: regarding odb, ISTR there is some issue with using #load on Wundows/Cygwin
<gildor>
kaustuv: there is also some issues, with the fact, that it don't set prefix or OCAMLFIND_DESTDIR= for oasis build
<gildor>
(prefix -> for oasis build and make install)
sepp2k has quit [Ping timeout: 250 seconds]
edwin has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
Yoric has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
eye-scuzzy has quit [Quit: leaving]
eye-scuzzy has joined #ocaml
sepp2k has joined #ocaml
jdavis has quit [Ping timeout: 272 seconds]
ygrek has quit [Remote host closed the connection]
Amorphous has quit [Read error: Operation timed out]
mnabil has quit [Read error: Connection reset by peer]
Amorphous has joined #ocaml
jdavis has joined #ocaml
eye-scuzzy has quit [Quit: leaving]
eye-scuzzy has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
<vivanov>
to use with ocamldoc, i want to create references to other definitions: for example i will have smth like (** A function used by <<val OtherModule.prices>> *), and after compiling to html documentation i want to click the word prices and get to prices definition in the documentation. What should i put instead of <<OtherModule.prices>> ?
<thomasga>
[OtherModule.prices]
<vivanov>
(** A function used by [OtherModule.prices] *) , right?
<vivanov>
thanks a lot
_andre has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
ftrvxmtrx has joined #ocaml
lamawithonel has joined #ocaml
ttamttam has joined #ocaml
oriba has joined #ocaml
myu2 has quit [Remote host closed the connection]
lopex has joined #ocaml
Yoric has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
myu2 has joined #ocaml
lamawithonel has quit [Ping timeout: 264 seconds]
Oejet has joined #ocaml
olegfink has quit [Ping timeout: 240 seconds]
ftrvxmtrx has quit [Remote host closed the connection]
ftrvxmtrx has joined #ocaml
<adrien>
bah: afaict, using pango to draw over a gtk pixbuf which is linked to a gtkimage won't auto-update the display, and I have to write something as stupid as "image#set_pixmap image#(get_)pixmap"
<oriba>
hello, when do I need Array.copy?
<oriba>
I used an array inside a record
<mrvn>
when you want a copy of an array
<oriba>
moment
<oriba>
I used a record and it contains an array
<oriba>
the array will be changed
<oriba>
and one function just gives back that array
<oriba>
another func is using the extraction of the array and writes it to a loist
<mrvn>
then you need a copy or all other references to the array will change as well
<oriba>
result: all list entries contain the same array
<oriba>
not the changed array
<oriba>
it's always just a pointer?
myu2 has quit [Remote host closed the connection]
<flux>
ocaml never copies anything by value
<oriba>
ok
<oriba>
for lists I would expect it
<flux>
(or if it does, you cannot really detect it)
<mrvn>
everyhing is always a pointer that isn't a trivial value (char, int, bool, unit)
<oriba>
with Array I think imperative ;)
<flux>
((well, with == perhaps, but don't do it ;-)))
<oriba>
but string can be changed in place
<mrvn>
oriba: a string is still a pointer
<oriba>
ah ok
<oriba>
so what I created without Array.copy was a list that points to the same array every time
<oriba>
change the code was easy
<oriba>
but I just wanted to know the background
<mrvn>
# let s1 = "hallo" in let s2 = s1 in s2.[0] <- 'H'; s1;;
<mrvn>
if I ever get around to write my ow ocaml like compiler then it will have const, read-only and read-write strings.
<flux>
batteries has BatString.Cap
<kaustuv>
what is the diff between const and readonly?
<flux>
but it would need to be quite pervasive to be really useful..
<mrvn>
oriba: string_of_bool true returns a pointer to the literal "true", then you change it to grue and the next call returns the same pointer.
<flux>
kaustuv, I guess const couldn't vary, while readonly could vary but you wouldn't be able to mutate it
<mrvn>
kaustuv: const can never change, read-only can not be changed by you.
<oriba>
mrvn, is this a security boittleneck?
<mrvn>
oriba: it's just how ocaml is
<flux>
actually one needs to be careful with the module I mentioned as well
<oriba>
hmhh.... it throws index out of bounds if I try some too long strings
<oriba>
ok
<flux>
as conversions from plain strings happens with %identity
* oriba
thoughts about code injection
mcclurmc has quit [Remote host closed the connection]
mikemc has quit [Remote host closed the connection]
<mrvn>
oriba: nah. you cn only change the contents of the string. The string itself is limited in length.
<mrvn>
The code is just something like this: let string_of_bool = function true -> "true" | false -> "false"
<kaustuv>
let module String = struct open String let set s x = failwith "no can do" end in let s = "hello" in s.[0] <- 'j';;
mcclurmc has joined #ocaml
<kaustuv>
err, let s x c = ...
<mrvn>
Warning X: this argument will not be used by the function.
<oriba>
mrvn, if I would rely on the "true" string somewhere in code, this might become a problem ;)
<mrvn>
I would have thought you get a type error because "set s x" isn't a char ref
<kaustuv>
oriba: Not all occurrences of the literal "true" map to the same location. The OCaml compile just "cleverly" lifts the constant string literals out of functions like string_of_bool
<kaustuv>
If you live by the rule that you never modify a string you didn't create yourself, you'll be fine.
<oriba>
hmhh... or only modify after copying...
<mrvn>
kaustuv: isn't it just that string literals are created at compile time?
<kaustuv>
I'm not sure if every string literal is lifted out at compile time, but that may well be the case
<mrvn>
kaustuv: what would be the point of creating it? you would just ahve to stroe the string verbatim and then memcpy it into a string value. Might as well add the extra word for the string header to it directly.
<mrvn>
/stroe/store/
<thelema>
kaustuv: what about #load? do you mean running ocaml with a file as argument?
<thelema>
gildor: thanks for noticing the OCAMLFIND_DESTDIR bug
<kaustuv>
mrvn: the point would be preserving the natural semantics. The string_of_true example demonstrates that it is not always safe to lift mutable values out of closures
<kaustuv>
thelema: I once ran into an issue with the ocaml toplevel on Cygwin not being able to #load "unix.cma". This was in 3.10.2 and Windows XP, I believe. It might be fixed now.
<thelema>
kaustuv: I'm not #loading, I'm #requiring
<kaustuv>
Well, it uses #load internally
<thelema>
ah. that sucks
<kaustuv>
I'm sure someone can check that it is still broken. Maybe Alain Frisch's dynamic dll gizmo fixes it
<mrvn>
kaustuv: that depends on how you define the behaviour of a string literal. Is it a value or is it creating a new value every time?
<mrvn>
kaustuv: depending on that you can allways or ever lift it.
<flux>
to me it appears strings literals are only ever constructed exactly once
<flux>
if there are multiple equal strings, they are not combined
thelema_ has joined #ocaml
<mrvn>
flux: that would really screw up semantics.
<flux>
it might even be a non-trivial win when dealing with basically consant strings
<flux>
mrvn, follow the rules outlined by kaustuv and you'll be fine ;)
<rwmjones>
anyone using erlang? is HiPE (the native code compiler) a usable option for production now?
<mrvn>
flux: you would have to do a whole code analysis to see if a string literal is constant or not.
<kaustuv>
rwmjones: Can't you ask #erlang?
<mrvn>
rwmjones: sorry, we all use .net here.
<rwmjones>
well, I could do, was hoping for a non-partisan view :-)
<flux>
mrvn, if you want to play safe, replace all string literals with String.copy string litreal
<mrvn>
flux: that would change the semantics.
thelema has quit [Ping timeout: 276 seconds]
<rwmjones>
anyway, as it turns out, #erlang doesn't let me comment, so no
<kaustuv>
rwmjones: wow, really?
<mrvn>
flux: currently in ocaml a literal is a single value created as compile time. One just has to know that and act acordingly. Holds true for strings, records, tuples,...
<rwmjones>
kaustuv: well it may be I need to do something to prove I'm not a spammer ... it's not immediately obvious from the /topic of that channel
<kaustuv>
Since the topic on #erlang was set by orbitz who's also here, maybe he can help
<rwmjones>
ok maybe I just had to identify myself to nickserv
* rwmjones
tries again
<rwmjones>
ah yeah, just because nickserv had forgotten about me
myu2 has quit [Remote host closed the connection]
fraggle_ has quit [Ping timeout: 240 seconds]
ftrvxmtrx has quit [Remote host closed the connection]
ftrvxmtrx has joined #ocaml
<adrien>
+R (and +q for unidentified) is really annoying and pretty useless currently
thelema_ has quit [Remote host closed the connection]
thelema has joined #ocaml
<gildor>
thelema: kaustuv is right, you should not #use or #require or #load, if you want something portable
<gildor>
(hehe, this was one of the initial draft of oasis's setup.ml, and one of the reason I have to copy a whole pile of stuff in it)
<thelema>
gildor: :(
<thelema>
I don't think I'll require compilation until this is verified and no workaround possible...
<thelema>
but thanks for the warning. Currently curl is required, and I dunno if that's available as part of default cygwin install
<thelema>
possibly this will end up only useful for unix
<gildor>
thelema: I think it is wget by default
<gildor>
and I am not even sure about that
<thelema>
now I just have to find some way to detect the two. Probably not too hard
<thelema>
Sys.command "where foo" <> 0
<gildor>
and anyway on Windows you should not rely on external software because it is not the way things are (TM)
<gildor>
(most Win32 exec comes as standalone apps with all their DLL and external software package together -> no dependencies on windows)
<thelema>
yes, but this is at best going to be a windows/cygwin programm, not win32
<gildor>
yes, you are right
<gildor>
and anyway, this is your program, so you choose your target
<gildor>
BTW, don't forget to use --prefix
<thelema>
--prefix for configure?
<gildor>
e.g. for ocamlify, it installs exec in bin/
<gildor>
yes
<kaustuv>
gildor: is #load/#use still broken with flexdll and ocaml 3.11.2+?
<gildor>
kaustuv: AFAIK, yes, cygwin target while very useful remains a secondary goal on windows
<kaustuv>
if I remember correctly, you can run the toplevel as: ocaml unix.cma pcre.cma whateverelse.cma
<gildor>
kaustuv: yes it works
<thelema>
fair enough - depending on the toplevel failure result from #load, we can just ask windows users to run odb differently
<thelema>
gildor: --prefix change pushed
fraggle_ has joined #ocaml
eye-scuzzy has quit [Quit: leaving]
eye-scuzzy has joined #ocaml
sepp2k has quit [Quit: Leaving.]
dnolen has joined #ocaml
<thelema>
And more important changes to package handling including instructions on how to set environment variables properly if they're not set
boscop has joined #ocaml
myu2 has joined #ocaml
sgnb has quit [Read error: Operation timed out]
sgnb has joined #ocaml
ymasory_ has quit [Quit: Leaving]
olegfink has joined #ocaml
alpounet has joined #ocaml
myu2 has quit [Remote host closed the connection]
<f[x]>
what do you mean by '#load is broken'?
<thelema>
f[x]: they seem to be claiming that it won't work under windows (and thus ocamlfind's #require won't work thus odb.ml won't work)
<thelema>
btw, does anyone know any tricks to get the same file to be compilable via ocamlfind as well as runnable standalone in ocaml via "#require"s?
lamawithonel has joined #ocaml
olegfink has quit [Ping timeout: 240 seconds]
lamawithonel has quit [Read error: Connection reset by peer]
lamawithonel has joined #ocaml
<f[x]>
it works and always worked for me (just checked on ocaml 3.11.0-mingw)
<thelema>
f[x]: great. That makes me feel better. would you be willing to test odb for me: https://github.com/thelema/odb
<f[x]>
sorry, not now
<thelema>
thanks anyway for looking into #load
<kaustuv>
note, I am not sure if it is still broken, and anyway it was a problem with cygwin
<f[x]>
you mean ocaml cygwin port?
* f[x]
wonders how many people do use that port
<kaustuv>
yes. More precisely, OCaml 3.10.2 + Cygwin 1.6.something + Windows XP had a broken #load in 2009
<f[x]>
I never tried cygwin port
<kaustuv>
actually, it was probably Cygwin 1.5.something. It was the stable branch before 1.7.
<thelema>
well, I look forward to the first bug or success report from someone running cygwin
* thelema
might implement the dumbest HTTP client ever to work around this
myu2 has joined #ocaml
tauntaun has joined #ocaml
<kaustuv>
don't you need cygwin to compile the mingw version of ocaml?
<flux>
thelema, but then you'll likely screw people with http proxies :)
<thelema>
flux: with non-transparent proxies, yes. blah.
<thelema>
maybe only people without curl and with non-transparent proxies
kaustuv has quit [Quit: rootin' tootin' rebootin']
<thelema>
and I'm explicitly trying to be an 80% solution (well, maybe 90%), so I don't have to contort my code that much for exceptional cases
vivanov has quit [Ping timeout: 252 seconds]
vivanov has joined #ocaml
dnolen has quit [Quit: dnolen]
larhat has quit [Quit: Leaving.]
lopex has quit []
ttamttam has quit [Remote host closed the connection]
ftrvxmtrx has quit [Remote host closed the connection]
ftrvxmtrx has joined #ocaml
er98052 has joined #ocaml
<mrvn>
Sending HTTP/1.1 isn't really more work than a dumb HTTP/1.0 client.
olegfink has joined #ocaml
<thelema>
mrvn: you're welcome to implement http_get : string -> string for me
<mrvn>
thelema: The only thing you need for proxy support is to send an extra "Host: <host>" in the header. That really isn't worth saving.
<mrvn>
and some option to specify the proxy url.
<thelema>
and I'll have to send that request to the proxy server somewhere, possibly with authentication ... ick
<mrvn>
ok, screw proxies with auth. :)
<thelema>
:)
<mrvn>
unless you support http server with auth in your dumb client. Then you already have the code there.
<mrvn>
but at that point it makes more sense to require curl
<thelema>
Unlikely
<gildor>
thelema: why not use ocurl ?
<thelema>
gildor: dependencies - one can't just install ocaml and findlib and be ready to use it
<mrvn>
Does anyone know of a image viewer (module) in ocaml?
<thelema>
it makes no sense for the program to install ocaml packages to require many ocaml packages to use it. chicken/egg
<thelema>
mrvn: it's not much more than a wrapper around lablgtk's GdkPixbuf
<thelema>
gildor: I bet this is easier, despite the restrictions
<thelema>
I don't have to generate binaries for the gazillion possible systems it could run on just fine
kaustuv has joined #ocaml
<thelema>
I still like the idea of curl -O http://db.o.o/odb.ml; ocaml odb.ml <packagename>
<thelema>
more specifically, ocaml odb.ml batteries
<gildor>
I don't want to be bashing about that, but why not start by adding _oasis to batteries ?
<mrvn>
What I want to do is write an interactive mirror script for google images. You give it some search terms and it downloads images from googles page and displays them. You then score images images and it branches out to fetch similar images. Highest score first.
<thelema>
mrvn: how to get search term for an image result?
lopex has joined #ocaml
<thelema>
gildor: on my todo list still.
<mrvn>
thelema: the use gives the initial term (or just the url to start from) and then it follows links.
<mrvn>
s/use/user/
<mrvn>
thelema: ever noticed the "similar images" link below results in an image search?
<thelema>
mrvn: nope. if there's that, that solves what I was thinking of...
<thelema>
then what you want to do seems pretty reasonable
ttamttam has joined #ocaml
vivanov has joined #ocaml
<mrvn>
thelema: for other pages I intend to just follow all links and prioritize those branches with high scores.
olegfink has quit [Read error: Operation timed out]
<mrvn>
One thing that would be nice would be code to say if 2 images are the same just with different resolution or quality.
enthymeme has joined #ocaml
<mrvn>
i.e. my own "similar images" filter.
<thelema>
I don't know how that's done, but the geeqie project has code for that.
<kaustuv>
thelema: an absolute noob would not have the wherewithall to run ocaml odb.ml batteries, and a less than absolute noob would be able to use oasis (once it's ready).
<kaustuv>
So I am a bit surprised you're trying to roll your own package manager
<mrvn>
kaustuv: you just click at runme.bat
thelema_ has joined #ocaml
jonafan is now known as jonathanhasasupe
<kaustuv>
I think the Haskell Platform-like approach is better for people who like clicking on things
jonathanhasasupe is now known as jonafan
philtor has joined #ocaml
thelema has quit [Read error: Connection reset by peer]
<thelema_>
mrvn: it doesn't seem to be maintained, and has had some security flaws reported (and maybe fixed in packaged versions)
oriba has quit [Quit: Verlassend]
Yoric has quit [Quit: Yoric]
orbitz_ has joined #ocaml
ikaros has joined #ocaml
orbitz has quit [Ping timeout: 260 seconds]
orbitz_ has quit [Client Quit]
orbitz has joined #ocaml
olegfink has joined #ocaml
<thelema_>
gildor: what is filesAB: in an _oasis file?
boscop_ has joined #ocaml
boscop has quit [Read error: Connection reset by peer]
ygrek has quit [Ping timeout: 252 seconds]
ygrek has joined #ocaml
thelema has joined #ocaml
bacam_ has joined #ocaml
avsm2 has quit [Ping timeout: 240 seconds]
bacam has quit [Ping timeout: 240 seconds]
thelema_ has quit [Ping timeout: 240 seconds]
boscop_ is now known as boscop
bacam_ is now known as bacam
avsm2 has joined #ocaml
<hcarty>
thelema: I think it is maintained, but it seems to be moving rapidly from location to location...
bacam has quit [*.net *.split]
sgnb has quit [*.net *.split]
flux has quit [*.net *.split]
fraggle_ has quit [*.net *.split]
patronus has quit [*.net *.split]
vouillon has quit [*.net *.split]
<thelema>
hcarty: really? whoa. it has a new website, and its version number has jumped. I guess I was wrong about thta.
<hcarty>
thelema: I was under the same impression until searching and finding that link just now...
<adrien>
wow
bacam has joined #ocaml
sgnb has joined #ocaml
flux has joined #ocaml
fraggle_ has joined #ocaml
patronus has joined #ocaml
vouillon has joined #ocaml
<thelema>
and it has a hg tree, with commits within the last year
<hcarty>
It's all very pleasantly surprising
<adrien>
10 months ago, I guess everyone had gotten desperate
boscop_ has joined #ocaml
<thelema>
yup, that's when it was picked up by camlspotter(?)
<thelema>
and I even find another personal standard library: spotlib
kaustuv_ has joined #ocaml
boscop has quit [Ping timeout: 264 seconds]
<hcarty>
thelema: Ulib from the Caml Bazaar may be worth stealing from as well
boscop_ is now known as boscop
<thelema>
I wish I could say spotlib was full of gems, so far I've found only hashset - sets implemented using hashtbl and a "phantom_head" module that does something scary with Obj.magic
<thelema_>
oriba: if you didn't really want named parameters, it's my first example - let f : int -> int = fun x -> x + 1
<oriba>
ok
<oriba>
but then there also are names...
<oriba>
after the "="
<thelema_>
gildor: not at this point. It looks like it'll take some work to migrate batteries to oasis. I see a lot of things being automatable
<thelema_>
let <identifier> : <type> = <value>
<oriba>
ah ok
<thelema_>
identifier is your function name, type is the type you want it to have, and value is "fun <params> -> ..."
<gildor>
thelema_: what kind of thing are automatable ?
<oriba>
and now it works
<oriba>
thanks a lot, thelema_ :)
<thelema_>
oriba: you're welcome
<thelema_>
gildor: some of the parameter substitution and dependency checking
<gildor>
thelema_: don't understand, this is done in oasis ?
<thelema_>
gildor: this could be done in oasis, no?
<gildor>
yes, so that is not missing
<thelema_>
the AB stuff
<gildor>
indeed
<gildor>
have you commited the resulting _oasis file, maybe I can make some comment about it
<thelema_>
Oasis might be able to cut down the number of repetitions of new module names in order to include a module (batteries_uni.mllib, batteries.mllib, batteries.ml)
<thelema_>
one sec
<gildor>
I don't know enough batteries to say that, but I know that some works has been done about this topic in extunix