<caseyjames>
Hi, I'm just getting started hands on with ocaml. How can I generate a list where each value equals the last generated value plus a new random generated value?
void64 has quit [Ping timeout: 264 seconds]
<Drup>
caseyjames: did you tried to write a first version ?
pkrnj has joined #ocaml
<caseyjames>
let rand_add length = let rec aux cpt sum acc = if cpt < 0 then acc else let new_sum = (sum + ((Random.int 8) * 480) in aux (cpt-1) new_sum (new_sum::acc) ;;
q66 has quit [Quit: Leaving]
walter|r has quit [Ping timeout: 260 seconds]
watermind has quit [Read error: Connection reset by peer]
walter|r has joined #ocaml
<Drup>
this seems quite good, you just have a small parenthesis issue
<Drup>
and of course, you lack the end, you need to "launch" the internal function
<caseyjames>
what parenthesis am I missing?
<Drup>
not missing, there is one too much after "new_sum"
manud has quit [Read error: Connection reset by peer]
manud has joined #ocaml
<caseyjames>
ahh got it. Is this generally an ok form to use, Are there any glaringly obvious mistakes?
<caseyjames>
let rand_add length = let rec aux cpt sum acc = if cpt < 0 then acc else let new_sum = (sum + ((Random.int 8) * 480) in aux (cpt-1) new_sum (new_sum::acc) ;;
<Drup>
still missing the end :)
<caseyjames>
sorry about that: let rand_add length = let rec aux cpt sum acc = if cpt < 0 then acc else let new_sum = (sum + ((Random.int 8) * 480)) in aux (cpt-1) new_sum (new_sum::acc) in aux length 0 [];; rand_add 12;;
weie has joined #ocaml
<Drup>
this seems correct
<Drup>
don't forget to initialize the seed for the random module
<caseyjames>
Cool, Ill look into that. I'm just very happy to have one function working. I've been retyping the 99 problems to get a feel for it, but carrying values over from previous iterations has alluded me
weie_ has quit [Read error: Connection reset by peer]
weie has joined #ocaml
ollehar has quit [Ping timeout: 256 seconds]
Arsenik has joined #ocaml
<kerneis>
gasche: thanks
Arsenik has quit [Ping timeout: 260 seconds]
<rks`>
gasche: I'm having a look
ontologiae has quit [Ping timeout: 264 seconds]
cago has joined #ocaml
chambart has quit [Ping timeout: 256 seconds]
q66 has joined #ocaml
Neros has quit [Ping timeout: 245 seconds]
Neros_ has joined #ocaml
chambart has joined #ocaml
Arsenik has joined #ocaml
Neros_ is now known as Neros
chambart has quit [Ping timeout: 260 seconds]
Neros_ has joined #ocaml
<rks`>
gasche: manual.md:A simple program , you call « ocamlbuild foo.byte » whereas you should call « ocamlbuild myprog.byte »
<rks`>
(you do the same for the .opt)
Neros has quit [Ping timeout: 260 seconds]
Neros_ is now known as Neros
<rks`>
also, I thought [-use-ocamlfind] was the default in 4.01, has it been reverted?
tane has quit [Remote host closed the connection]
tane has joined #ocaml
Neros has quit [Ping timeout: 245 seconds]
Arsenik has quit [Remote host closed the connection]
<hcarty>
rks`: On 4.01.0 a simple test makes it look like there is some kind of default support but it may be a little broken
breakds has joined #ocaml
ollehar has joined #ocaml
<hcarty>
rks`: With "open Batteries" in test.ml, "ocamlbuild test.native" fails as expected. "ocamlbuild -package batteries test.native" works but gives a warning saying 'Warning: tag "package" does not expect a parameter, but is used with parameter "batteries"'
dsheets has quit [Read error: Operation timed out]
walter|r has quit [Read error: Connection reset by peer]
<pippijn>
so then p1' : 'a exprsets, p2' : 'b exprsets
<whitequark>
perhaps you could add a user-specified function 'a -> 'b -> 'c
<whitequark>
which combines return values
<whitequark>
does that make sense?
<pippijn>
uhm
walter|r has joined #ocaml
<pippijn>
let me think about that
<pippijn>
so, you have the pattern (x:a)(y:3)
<pippijn>
where x : char -> int = fun c -> Char.escaped c
<pippijn>
eh
<pippijn>
-> string
<pippijn>
and y : char -> int = fun c -> Char.code '0' - Char.code c
<whitequark>
scratch that, I think it doesn't
<whitequark>
hmm
<pippijn>
now let's first just consider derivatives, not partial derivatives
<pippijn>
the derivative of (a3) over 'a' is (3)
<pippijn>
(x:a)(y:3) \ a = ε(y:3)
<pippijn>
actually: (x:ε)(y:3)
<gasche>
bernardofpc: thanks, I'll integrate your comments
<pippijn>
so that still works, but then in the next step, x is nullable
<pippijn>
because ε accepts the empty word ε
zbroyar has joined #ocaml
<adrien>
quick poll
<adrien>
who has used lablgtk and actually read the README?
<whitequark>
pippijn: why is nullability a problem?
<pippijn>
ok
<pippijn>
in a simplified way:
<pippijn>
(a)(ab) \ a = (ab)
<pippijn>
(a?)(ab) \ a = (ab) + (b)
<pippijn>
a? is nullable, so the derivative of (a?)(ab) has the choice to let (a?) take the a, or skip it (because it's optional) and let (ab) take the a
<pippijn>
you can only know which one was correct in the next step
<whitequark>
oh, so this is backtracking vs not backtracking
<pippijn>
this is not backtracking
<pippijn>
it's an NFA
<whitequark>
ok
<pippijn>
so yeah, instead of backtracking and possibly consuming the same input many times
<pippijn>
we consume the input once and stay in every possible branch at the same time
<whitequark>
right
<kerneis>
rm -rf ~/.opam # frozen during 20 seconds…
<pippijn>
bad I/O scheduler
<adrien>
pffffft, rm -rf ~/t/yypkg
<kerneis>
oh, the machine probably wasn't; it was over ssh
<adrien>
frozen for 8 minutes
<adrien>
dozens of GCC builds; 3,3M files and 150GB
<kerneis>
:-)
darkf has quit [Read error: Connection reset by peer]
darkf has joined #ocaml
ontologiae has quit [Read error: Connection reset by peer]
<gasche>
companion_cube: no I'm not, I'm just referencing it in case you'd be interested
ontologiae has joined #ocaml
<gasche>
in fact Stéphane Lengrand has a paper on the design of a new proof assistant based on this
<gasche>
which is rather interesting
zbroyar has quit [Quit: Leaving.]
<gasche>
rks` , hcarty : -use-ocamlfind is not default for 4.01 as far as I know
<gasche>
the making-it-default patch was only commited in trunk because avsm had reservations about it
zbroyar has joined #ocaml
sam__ has joined #ocaml
saml has quit [Ping timeout: 246 seconds]
<gasche>
pippijn: I only got the recent glimpses of your discussion of GADTized regexps and derivatives
<rks`>
ok
<gasche>
you didn't get to what the problem was; is it hard to get a type for the derivation operation?
sam__ is now known as saml
void64 has joined #ocaml
<pippijn>
gasche: yes
hellome has quit [Read error: Connection reset by peer]
hellome has joined #ocaml
ollehar has quit [Ping timeout: 240 seconds]
<adrien>
I'm after a markup-like tool that produces html, any idea?
<adrien>
not too many deps though
<pippijn>
like markdown, restructuredtext, pod, ...?
<adrien>
any for which the source is still human-readable
<adrien>
(close to a README file actually)
<pippijn>
I think markdown and rst are ok
<gasche>
adrien: pandoc being a nice tool to manipulate markdown files
<gasche>
(plus it's written in Haskell)
ontologiae has quit [Ping timeout: 260 seconds]
<adrien>
I thought about pandoc but it's a pain to get for me
<adrien>
it's absolutely huge unfortunatley
<pippijn>
I might need something like pandoc
<pippijn>
for my website
<adrien>
hmm, I think I'm going to use asciidoc
<pippijn>
I need a DOM or SAX like interface to the text structure
<pippijn>
I need something that gives me a parse tree
<adrien>
asciidoc gives you xml
<pippijn>
because of the way I do source code highlighting
<adrien>
I'm actually happy to not have used markdown or something similar
<gasche>
bernardofpc: I integrated your remarks, thanks; the one I didn't implement for some readon are http://ocaml.xelpaste.org/8217
<gasche>
adrien: why?
<adrien>
even though I'm only starting and they would have been suitable, I guess they would have become bad after a while
<adrien>
docbook (or actually asciidoc here) might be a bit heavier but they're also more future-proof
<gasche>
hm
<gasche>
well once your text is in markdown-like syntax it's easy to convert into HTML and mostly everything from there
<gasche>
I suspect pandoc may even have a markdown->LaTeX tool
<adrien>
you still need to have a table of contents, need to handle multiple pages and links between them, ...
chris2_ has joined #ocaml
chris2_ is now known as chris2
<gasche>
(pandoc does handle table of contents, but I suspect for cross-page links you'd directly refer to produced URLs, which break the abstraction for non-web documents)
<hcarty>
gasche: Thank you for the clarification on ocamlbuild. It looks like something may have slipped through into 4.01.0, maybe a partial commit somewhere.
<gasche>
I'm not sure what you felt was wrong in the behavior you reported, can you precisely quote the problem?
<gasche>
the fact that without -use-ocamlfind the error message is rubbish (when it fails) is known
<gasche>
if I understand correctly, your surprise is that sometimes it still works without -use-ocamlfind; I'd expect that to be a chance hit of the pre-ocamlfind-plugin code that, I think, works with -pkg or -package command-line option
<pippijn>
adrien: much
<gasche>
(but I don't know much about how and when it works; I've mostly been interested in deprecating it as an interface users see, except maybe reusing some of the code for performance optimization purposes)
<gasche>
also there is the fact that the ocaml compiler will not complain if an "open Foo" that is not actually used at runtime is not followed by actually linking the module (finding the .cmi may be enough); but I don't think that was the issue
<adrien>
I'm not done yet; still many small things to fix and generally-speaking, there are too many things in that file
<gasche>
adrien: how are your slides for OUPS going?
<gasche>
and did you actually notify the OUPS organizers that you wanted to talk?
<adrien>
haven't had much time lately and rks` asked me to wait until october so that we would be back
<adrien>
agreed
<adrien>
and that'll give me time to get some feedback
Neros has quit [Ping timeout: 268 seconds]
walter|r has quit [Quit: This computer has gone to sleep]
void64 has quit [Ping timeout: 260 seconds]
<rks`>
haha adrien
<rks`>
that's really low.
<wmeyer>
hi rks` :-)
<wmeyer>
hi adrien & gasche
<wmeyer>
hi pippijn
<rks`>
hello
<pippijn>
hi wmeyer
<adrien>
rks`: :o
<adrien>
hi wmeyer
talzeus has quit [Read error: Connection reset by peer]
talzeus__ has joined #ocaml
<pippijn>
wmeyer: did you see the cpapa-online?
<wmeyer>
the frontend in a browser, some time ago
<pippijn>
yesterday?
<pippijn>
because I added it yesterday
<wmeyer>
yes, but i have to admit i was not sure if I did after the update, sorry
<gasche>
when the linker is concerned, "blame Apple" also works fairly well
<adrien>
wmeyer: have time to fix your svn? :D
<wmeyer>
adrien: promise to do it today in the evening? :-) , i have to do my daytime job now!
<adrien>
no worry :D
ollehar has joined #ocaml
skchrko has joined #ocaml
<gasche>
I got a syntax error because I named a variable "mod"
<gasche>
we need to special-case those
<wmeyer>
adrien: yeah, I want to commit these patches :-) I really want them in.
<pippijn>
it's an unlikely situation anyway
<pippijn>
I've never encountered it, but it can be produced
<pippijn>
nobody puts __ in their module name :)
<wmeyer>
pippijn: why not
<wmeyer>
it might be a second level delimiter
<pippijn>
ok
<wmeyer>
you can have: FOO__Bar_One_Two
<wmeyer>
so it will be mangled most likely
<pippijn>
but you'll rarely link that with a pack "FOO" containing module Bar_One_Two
<wmeyer>
encoded in such way it can be reproduced, avoiding collisions
<wmeyer>
pippijn: right, only if pack where a good engineering solution
<pippijn>
pack hack
<wmeyer>
yes, it's a hack
<wmeyer>
but I have to admit, that these kind of hacks rarely happen in OCaml :-)
<rks`>
new reason why core(_kernel) cannot be used on windows, « camlCore_kernel__Std_kernel__Array__ » takes 36 chars, nasm ignores all chars after the 31st
<wmeyer>
:D
<wmeyer>
the names of the functions in C++ can have even 1KB length of characters
<rks`>
s/nasm/masm/
<wmeyer>
If i was MS i'd ignore it too
<wmeyer>
you know that Excel cell can't exceed 1KB
<wmeyer>
probably it;s the same data type, or shared constant among their headers in the codebase
<wmeyer>
oh sorry you mean 36 characters, that's bad
<adrien>
if there's anything you'd like to see added or anything you find confusing, tell me
<adrien>
pippijn: btw, how did you find out that you were missing the GTK+ init last night?
Kakadu has quit [Quit: Konversation terminated!]
<Drup>
I told him :)
<adrien>
you recognized the error message?
chrisdotcode has joined #ocaml
<Drup>
no, I looked at the code and didn't see any GMain.init()
<adrien>
ok, thanks
<adrien>
hmm, also, anyone has a smartphone? or any device with a small and high-dpi screen? is the width of this webpage fine http://lablgtk.forge.ocamlcore.org/ ?
<Drup>
adrien you should turn this into an ocamldoc page to autogenerate link to the relevant documentation and have ocaml coloring and all
<rks`>
ha ha.
<Drup>
adrien : tbh, an user mostly don't care about the files in the distributed archive. the index of the exported module is more relevant.
<adrien>
still not sure how to improve that: I want to have this page and the README file in the source archive be the same
<adrien>
(at least, have the same content)
<adrien>
but it's pretty certain this section is going to go down in the page
bondar has quit []
talzeus__ has quit [Remote host closed the connection]
zpe has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
ollehar has joined #ocaml
<Drup>
adrien also, lablgtk is the textbook example of library which really need simple code snippets to get you started by (at first) stupidly copy paste things
<Drup>
(I'm not saying this should be in the readme, just expressing opinions)
<rks`>
second that
<adrien>
I plan to take on the tutorial again
<adrien>
but later
<adrien>
actually I need to re-read it
<adrien>
if it loads...
turnersr has joined #ocaml
<adrien>
but it's quite difficult: signals have become natural to me; but what about beginners?
<adrien>
anyway, I'll try to 10-minutes intro
<Drup>
I don't really use lablgtk (by lack of use case, not by dislike ;) so I will probably be able to tell you if something is not understandable
<adrien>
:)
<adrien>
I should also keep in mind that ocaml and also lablgtk are used to teach freshmen
n06rin has quit [Quit: Leaving.]
amirmc has quit [Quit: Leaving.]
amirmc has joined #ocaml
dnm has quit [Ping timeout: 268 seconds]
amirmc has quit [Client Quit]
dsheets has quit [Ping timeout: 268 seconds]
troydm has joined #ocaml
ygrek_ has quit [Ping timeout: 260 seconds]
chambart has quit [Ping timeout: 260 seconds]
TDJACR has joined #ocaml
turnersr has quit [Ping timeout: 264 seconds]
chambart has joined #ocaml
turnersr has joined #ocaml
zpe has joined #ocaml
jpdeplaix has quit [Ping timeout: 276 seconds]
Xom has joined #ocaml
Xom has quit [Client Quit]
zpe has quit [Ping timeout: 264 seconds]
structuralist has joined #ocaml
jpdeplaix has joined #ocaml
Neros has joined #ocaml
ollehar has quit [Ping timeout: 264 seconds]
darkf has quit [Quit: Leaving]
zpe has joined #ocaml
<adrien>
the merge from 4.01 to trunk must have hurt :P
<rks`>
hm?
<adrien>
I'm sure I've caused a lot of conflicts with my changes to the build system :P
<adrien>
but it was deserved! Damien Doligez had caused me many conflicts first!
zpe has quit [Ping timeout: 264 seconds]
zpe has joined #ocaml
ggole has quit []
zpe has quit [Ping timeout: 264 seconds]
ontologiae has joined #ocaml
<skunkwerks>
I'm just starting with ocaml via the almost-released Real World OCaml book, which advises me to install 4.1.0, and I can see a -rc.1 tag in git/svn now.
<skunkwerks>
Is there some clever way for me to get from 4.00.1 which I have via OSX `brew install objective-caml opam` to 4.1.0-rc1 ?
<Drup>
skunkwerks: beware that 4.01.0 is indeed in beta. Final and quite stable beta, but still beta.
<skunkwerks>
Drup: sure. I thought I read somewhere there's some smart way to upgrade between versions. not sure.
<Drup>
not afaik, you can use an old ocaml version to install opam and use it to install new versions easily, but that's all (and that's just convenient, not necessary)
zbroyar has quit [Quit: Leaving.]
turnersr has quit [Ping timeout: 256 seconds]
turnersr has joined #ocaml
ulfdoz has joined #ocaml
<hcarty>
gasche: Your 'if I understand correctly' is correct