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
tmaeda0 has joined #ocaml
tmaeda has quit [Read error: 110 (Connection timed out)]
crink has joined #ocaml
lanaer has quit [Read error: 104 (Connection reset by peer)]
lanaer has joined #ocaml
BigJ2 has joined #ocaml
tmaeda0 is now known as tmaedaZ
<BigJ2> I was wondering what I am doing wrong with this function trying to add elements to a list...
<mrvn> you are trying to prepent a list to an int
<mrvn> do you mean a := !a @ [i]?
lanaer has quit [Read error: 113 (No route to host)]
<BigJ2> ya that's what I was trying to do
<BigJ2> just simply add elements to the list
<mrvn> you should do that recursive
<BigJ2> instead of a for loop?
<mrvn> yes
<BigJ2> k
<BigJ2> I'll try making a recursive version.
lanaer has joined #ocaml
<BigJ2> I am just messing around right now trying out different things
<mrvn> # let rec create_list = function 0 -> [] | x -> x :: (create_list (x - 1));;
<mrvn> val create_list : int -> int list = <fun>
<mrvn> # create_list 5;;
<mrvn> - : int list = [5; 4; 3; 2; 1]
<mrvn> let create_list x = let rec loop acc = function 0 -> acc | x -> loop (x::acc) (x-1) in loop [] x;;
<mrvn> # create_list 10;;
<mrvn> - : int list = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10]
<mrvn> something like that
<BigJ2> I am a little confused about recursion. basically it is a function that calls itself?
<mrvn> To understand recursion you have to first understand recursion
<mbishop> heh
<mrvn> The simple case is a function calling itself
<BigJ2> how does one know to use recursion as opposed to a loop?
<mrvn> you have that wrong: How does one know to use a loop as opposed to recursion?
<BigJ2> so look at recursion first and then consider loops
ikaros has quit ["Leave the magic to Houdini"]
<mrvn> loops are more of a convenience add-on for cases where they are simpler.
ztfw` has joined #ocaml
<BigJ2> k I'll have to take a closer look at recursion and come back with questions
BigJ2 has quit [Client Quit]
ztfw has quit [Read error: 104 (Connection reset by peer)]
<mrvn> Args, (int, int, c_layout) Array1.t gets translated as Pbigarray_unknown element type instead of Pbigarray_caml_int. Something is wrong there.
thieusoai has joined #ocaml
thrasibule has joined #ocaml
tmaedaZ is now known as tmaeda0
crink has left #ocaml []
tmaeda0 has quit ["Quit Nadoka 0.7.1-trunk (rev: 187) - http://www.atdot.net/nadoka/"]
tmaeda has joined #ocaml
crink has joined #ocaml
verte has joined #ocaml
crink has quit ["Leaving."]
Amorphous has quit [Read error: 110 (Connection timed out)]
Ched has quit [Read error: 60 (Operation timed out)]
Ched has joined #ocaml
Amorphous has joined #ocaml
eibmozoib has joined #ocaml
BigJ2_ has joined #ocaml
julm_ has joined #ocaml
crink has joined #ocaml
tmaeda is now known as tmaedaZ
tmaedaZ is now known as tmaeda
julm has quit [Read error: 110 (Connection timed out)]
tmaeda has quit ["Quit Nadoka 0.7.1-trunk (rev: 187) - http://www.atdot.net/nadoka/"]
tmaedaZ has joined #ocaml
<BigJ2_> I am looking at a recursive function. http://codepad.org/PmGZbPDQ
<BigJ2_> if I want it to return 1 after the first if statement, in c you would put return 1; how would I do that in ocaml?
<thelema> if foo then 1 else ...
<thelema> "if" isn't a statement, it's an expression, and as such, it returns a value
<thelema> like ? :
<BigJ2_> yes I did if n <= 1 then 1 else ....
BigJ2_ has quit [Client Quit]
<thelema> is there a problem with your code?
crink has quit ["Leaving."]
crink has joined #ocaml
BigJ2 has joined #ocaml
tmaedaZ is now known as tmaeda
BigJ2 has quit [Client Quit]
julm_ is now known as julm
infoe_ has joined #ocaml
julm has quit [zelazny.freenode.net irc.freenode.net]
Ched has quit [zelazny.freenode.net irc.freenode.net]
thieusoai has quit [zelazny.freenode.net irc.freenode.net]
lanaer has quit [zelazny.freenode.net irc.freenode.net]
mbac_ has quit [zelazny.freenode.net irc.freenode.net]
det has quit [zelazny.freenode.net irc.freenode.net]
ccasin has quit [zelazny.freenode.net irc.freenode.net]
deavid has quit [zelazny.freenode.net irc.freenode.net]
rwmjones has quit [zelazny.freenode.net irc.freenode.net]
c0m has quit [zelazny.freenode.net irc.freenode.net]
brendan has quit [zelazny.freenode.net irc.freenode.net]
ertai has quit [zelazny.freenode.net irc.freenode.net]
bind_return has quit [zelazny.freenode.net irc.freenode.net]
noj has quit [zelazny.freenode.net irc.freenode.net]
maskd has quit [zelazny.freenode.net irc.freenode.net]
tmaeda has quit [zelazny.freenode.net irc.freenode.net]
thrasibule has quit [zelazny.freenode.net irc.freenode.net]
ztfw` has quit [zelazny.freenode.net irc.freenode.net]
tab has quit [zelazny.freenode.net irc.freenode.net]
animist has quit [zelazny.freenode.net irc.freenode.net]
reid96 has quit [zelazny.freenode.net irc.freenode.net]
mfp has quit [zelazny.freenode.net irc.freenode.net]
Mr_Awesome has quit [zelazny.freenode.net irc.freenode.net]
lutter has quit [zelazny.freenode.net irc.freenode.net]
thelema has quit [zelazny.freenode.net irc.freenode.net]
schme has quit [zelazny.freenode.net irc.freenode.net]
bohanlon has quit [zelazny.freenode.net irc.freenode.net]
Dodek has quit [zelazny.freenode.net irc.freenode.net]
monestri has quit [zelazny.freenode.net irc.freenode.net]
TaXules has quit [zelazny.freenode.net irc.freenode.net]
eibmozoib has quit [zelazny.freenode.net irc.freenode.net]
rbancroft has quit [zelazny.freenode.net irc.freenode.net]
gim has quit [zelazny.freenode.net irc.freenode.net]
mattiase has quit [zelazny.freenode.net irc.freenode.net]
patronus has quit [zelazny.freenode.net irc.freenode.net]
munga_ has quit [zelazny.freenode.net irc.freenode.net]
jimmyb2187 has quit [zelazny.freenode.net irc.freenode.net]
munga has quit [zelazny.freenode.net irc.freenode.net]
tonyIII has quit [zelazny.freenode.net irc.freenode.net]
flux has quit [zelazny.freenode.net irc.freenode.net]
bacam has quit [zelazny.freenode.net irc.freenode.net]
hyperboreean has quit [zelazny.freenode.net irc.freenode.net]
orbitz has quit [zelazny.freenode.net irc.freenode.net]
mrvn has quit [zelazny.freenode.net irc.freenode.net]
__marius__ has quit [zelazny.freenode.net irc.freenode.net]
julm has joined #ocaml
Ched has joined #ocaml
thrasibule has joined #ocaml
thieusoai has joined #ocaml
ztfw` has joined #ocaml
lanaer has joined #ocaml
tab has joined #ocaml
mbac_ has joined #ocaml
det has joined #ocaml
ccasin has joined #ocaml
Dodek has joined #ocaml
animist has joined #ocaml
reid96 has joined #ocaml
deavid has joined #ocaml
monestri has joined #ocaml
mfp has joined #ocaml
Mr_Awesome has joined #ocaml
lutter has joined #ocaml
rwmjones has joined #ocaml
thelema has joined #ocaml
c0m has joined #ocaml
schme has joined #ocaml
bohanlon has joined #ocaml
brendan has joined #ocaml
ertai has joined #ocaml
bind_return has joined #ocaml
noj has joined #ocaml
maskd has joined #ocaml
TaXules has joined #ocaml
ccasin has quit ["Leaving"]
eibmozoib has joined #ocaml
rbancroft has joined #ocaml
gim has joined #ocaml
mattiase has joined #ocaml
patronus has joined #ocaml
munga_ has joined #ocaml
jimmyb2187 has joined #ocaml
munga has joined #ocaml
tonyIII has joined #ocaml
flux has joined #ocaml
bacam has joined #ocaml
hyperboreean has joined #ocaml
orbitz has joined #ocaml
mrvn has joined #ocaml
__marius__ has joined #ocaml
ccasin has joined #ocaml
tmaeda has joined #ocaml
jknick has quit ["Lost terminal"]
BigJ2 has joined #ocaml
BigJ2 has quit [Client Quit]
jknick has joined #ocaml
caligula__ has quit [Read error: 60 (Operation timed out)]
crink has left #ocaml []
caligula__ has joined #ocaml
thrasibule has quit [Read error: 110 (Connection timed out)]
ccasin has quit ["Leaving"]
caligula_ has joined #ocaml
BigJ has joined #ocaml
caligula__ has quit [Read error: 60 (Operation timed out)]
ski_ has joined #ocaml
ulfdoz has joined #ocaml
ski_ has quit ["Lost terminal"]
ski_ has joined #ocaml
verte has quit ["~~~ Crash in JIT!"]
ulfdoz has quit [Read error: 110 (Connection timed out)]
Submarine has joined #ocaml
thieusoai has quit ["leaving"]
ttamttam has joined #ocaml
ttamttam has quit ["Leaving."]
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
Mr_Awesome_ has joined #ocaml
ztfw` has quit [Remote closed the connection]
_zack has joined #ocaml
valross has quit [Read error: 60 (Operation timed out)]
Snark has joined #ocaml
ttamttam has joined #ocaml
valross has joined #ocaml
c0m has quit [Read error: 104 (Connection reset by peer)]
reid96 has quit [Read error: 104 (Connection reset by peer)]
valross has quit [Read error: 110 (Connection timed out)]
Yoric has joined #ocaml
prince has joined #ocaml
_zack has quit ["Leaving."]
kaustuv has joined #ocaml
_zack has joined #ocaml
Associat0r has joined #ocaml
tomaw has left #ocaml []
Associat0r has quit [Client Quit]
_zack has quit ["Leaving."]
dmentre has joined #ocaml
_zack has joined #ocaml
munga_ has quit [Read error: 113 (No route to host)]
<flux> is there a HTTP client for ocaml that'd be suitable to be used without threading but with concurrent connections?
<flux> or maybe a HTTP client that could easily be modified to do that..
<flux> but here's something I found while searching for it: a simple standalone HTTP-server for ocaml: http://upsilon.cc/~zack/hacking/software/ocaml-http/
<flux> iirc ocamlnet comes with one too, but it was GPL iirc?
<flux> (argh, excess use of acronyms)
<flux> actually that's GPL also ;)
<_zack> flux: ocaml-http is both multi-threaded and multi-process (you choose)
<flux> in any case, perhaps it's smipler to use
<_zack> ocamlnet has nethttpd, which is GPL-ed
<flux> _zack, well, multithreaded and multiprocess is equally bad
<flux> _zack, I'm looking for single-thread and single-process
<_zack> flux: well, that's what the company has to offer :-P
<flux> so, select, etc
<_zack> flux: ... and that's the third choice of ocaml-http ;-)
<_zack> but if you want performances, probably nethttpd is better
<flux> oh, right, and I'm looking for client, not server, don't let my googling confuse you :-)
<_zack> flux: ah
<_zack> flux: so neither ocaml-http nor nethtppd
<flux> otherwise ocsigen would probably suit my purposes
<flux> it uses LWT for 'threading'
<flux> I suppose I'll write yet another minimal http client for this
mfp has quit [Read error: 104 (Connection reset by peer)]
ikaros has joined #ocaml
mfp has joined #ocaml
Submarine has quit [Read error: 110 (Connection timed out)]
julm_ has joined #ocaml
julm has quit [Read error: 104 (Connection reset by peer)]
mbac_ has quit [Remote closed the connection]
julm has joined #ocaml
julm_ has quit [Read error: 104 (Connection reset by peer)]
julm_ has joined #ocaml
julm has quit [Read error: 104 (Connection reset by peer)]
gdmfsob has joined #ocaml
mishok13 has quit [Read error: 110 (Connection timed out)]
julm_ has quit [Read error: 60 (Operation timed out)]
julm has joined #ocaml
tmaeda is now known as tmaedaZ
<_zack> any well known example of writing a parser using CamlP4 (new) and ulex together?
rwmjones_lptp has joined #ocaml
rwmjones_lptp has quit ["This computer has gone to sleep"]
_zack has quit ["Leaving."]
julm_ has joined #ocaml
kaustuv_ has joined #ocaml
julm has quit [Read error: 60 (Operation timed out)]
kaustuv has quit [Read error: 113 (No route to host)]
_andre has joined #ocaml
tmaedaZ has quit ["Quit Nadoka 0.7.1-trunk (rev: 187) - http://www.atdot.net/nadoka/"]
tmaeda has joined #ocaml
Yoric has quit [Remote closed the connection]
_unK has joined #ocaml
mbac has joined #ocaml
alp_ has joined #ocaml
Alpounet has quit [Read error: 113 (No route to host)]
julm_ is now known as julm
ccasin has joined #ocaml
kaustuv_ has quit ["ERC Version 5.3 (IRC client for Emacs)"]
_zack has joined #ocaml
gdmfsob has quit ["Stopping IRC chat... [OK]"]
caligula_ has quit [Read error: 60 (Operation timed out)]
caligula_ has joined #ocaml
c0m has joined #ocaml
<rwmjones> gildor, URLs on the forge are "slippy"
<rwmjones> for example, I'm 99.9% certain that ocaml-pa-do used to have this URL:
<rwmjones> but that URL now downloads some completely different package (regstab)
<flux> fun feature :)
<flux> "surprise introductions to other projects"
<flux> "feel the inspiration!"
<flux> apparently the text after the last / is just feel-good nice-urliness
<flux> you can iterate over offered downloads by changing the number (well, yeah, obviously). but it looks like a database id, why would it change?
<flux> has there been a database revamp or something that would've changed the primary keys?
<rwmjones> the real url is 237 not 273 so maybe I typod it
<rwmjones> lucky we have tools here to detect this sort of thing, but even so
<rwmjones> downloading a package called "pa-do-*.tar.gz" should download pa-do, not something else entirely
julm has quit ["leaving"]
julm has joined #ocaml
<flux> I agere that that could be considered a bug. but not a serious one I think.
<flux> it still gives the right content disposition header
<flux> so if you download it with the web browser, which is 99% of the cases?, you'll get properly named archive
<flux> iow: if there are other things to fix/mend/make better, they are likely more important :)
<rwmjones> heh, massive C type safety fail: https://bugzilla.redhat.com/show_bug.cgi?id=533063
<gildor> rwmjones: just a typo... anyway if this feature is to be correct I will probably forward it to upstream GForge
<gildor> corrected
<rwmjones> agreed
<mrvn> I think that has no effect though. The application passes an __off64_t in a register and libc just passes that register along as is. Doesn't cut of the upper 32bit.
<gildor> rwmjones: feel free to submit the bug report against OCaml Forge Site admin project, or directly to fusionforge.org
<rwmjones> mrvn, you're kidding? people are rushing around Red Hat right now trying to find every app that might ever have been compiled using those 3 calls
<rwmjones> it's serious ... half of the 32 bits are garbage
<rwmjones> half of the 64 bits I mean
<mrvn> rwmjones: doesn't the user visible part use off_t?
<mrvn> hmm, my unistd.h says: extern ssize_t __REDIRECT (pread, (int __fd, void *__buf, size_t __nbytes, __off64_t __offset), pread64) __wur;
<Dodek> hey, ((+) 2) returns a function, but ((*) 2) doesn't - the compiler thinks it's a comment
<mrvn> rwmjones: is that a read-hat only bug?
<mrvn> -e
<Dodek> what should i do?
<mrvn> aeh, -a I mean
<mrvn> Dodek: (* starts a commen, ( * )
<rwmjones> mrvn, no, it's more subtle. If your 32 bit program called fallocate (fd, , , n) AND it was compiled with -D_FILE_OFFSET_BITS=64 (which everything is), then what is allocated is (rand () << 32) | n
<rwmjones> we found this because of an obscure data-corrupter in qemu, which no one could understand until we disassembled the code
<Dodek> oh. that's a bit nasty.
<Dodek> it reminds me of c++ and its foo<bar<baz>> vs foo<bar<baz> > problem
<mrvn> rwmjones: my unistd.h says to use 64bit. So unless the libc cuts of the upper 32bit later (which is easy to fix if it does) then the right things is done.
<flux> dodek, for that reason it is considered a uniform syntax to write ( + ) etc
<flux> mrvn, did you try the test case?
<Dodek> flux: well, that justifies it a bit.
<rwmjones> mrvn, no it affects all glibc users
<rwmjones> all who use pread/pwrite/fallocate anyway, which is why this is probably less of an issue than it might have been
<mrvn> p.c:25: warning: implicit declaration of function 'preadv'
<flux> my libc/linux doesn't have preadv, so I can't try :)
rwmjones is now known as rwmjones-afk
<mrvn> rwmjones-afk: If I change the test code to use pread() then I get:
<mrvn> pread64(3, "", 1, 281474976706303) = 0
<rwmjones-afk> preadv I think
<mrvn> Must be a RedHat exetension to glibc. No such thing here and pread() is just fine.
c0m has quit [SendQ exceeded]
<mrvn> Or recently added to glibc.
<mattiase> preadv/pwritev are fairly new in glibc, but have existed in BSD for quite some time (about 10 years it seems)
<mrvn> Addd in glibc 2.10 it seems.
<mattiase> But then *BSD never had the off_t size problems of Linux, because they used 64 bits from the beginning
<mrvn> Ok, updating libc6 to 2.10.1, fixing the testcase and then compiling with preadv shows the bug.
<mrvn> Needs #define _USE_BSD
<mrvn> Maybe we should create a libc7 and throw out all the legacy 32bit crap. LFS should really be default.
<mrvn> Throw out Unix and only have Unix.Largefile too.
ski_ has quit ["Lost terminal"]
ski_ has joined #ocaml
rwmjones_lptp has joined #ocaml
ccasin has quit [Read error: 110 (Connection timed out)]
seanmcl has joined #ocaml
<mattiase> mrvn: Yes, there is really no excuse at all to propagate mistakes in one syscall interface to another.
dmentre has quit ["Leaving."]
_andre has quit ["*puff*"]
julm has quit ["Lost terminal"]
julm has joined #ocaml
reid97 has joined #ocaml
ttamttam has quit ["Leaving."]
c0m has joined #ocaml
ulfdoz has joined #ocaml
sramsay has joined #ocaml
sramsay has left #ocaml []
_zack has quit ["Leaving."]
Yoric[DT] has joined #ocaml
albacker has joined #ocaml
Mr_Awesome_ has quit [Read error: 110 (Connection timed out)]
ulfdoz has quit [Read error: 110 (Connection timed out)]
ikaros has quit ["Leave the magic to Houdini"]
Submarine has joined #ocaml
ttamttam has joined #ocaml
ccasin has joined #ocaml
ygrek has joined #ocaml
tmaeda is now known as tmaedaZ
tmaedaZ is now known as tmaeda
tmaeda has quit [Remote closed the connection]
tmaeda has joined #ocaml
tmaeda is now known as tmaedaZ
slash_ has joined #ocaml
thieusoai has joined #ocaml
<thieusoai> why does this one gives these errors ?
<thieusoai> warnings rather
<thieusoai> # let c=ref 1 in let uONE = 1 in match !c with |uONE -> Printf.printf "ONE" | _ -> ();;
<thieusoai> Warning Y: unused variable uONE.
<thieusoai> Warning U: this match case is unused.
<brendan> you can't use variables in patterns like that. in that case, you're shadowing your outer uONE with whatever !c happens to be
<brendan> you can do something like: with |x where x = uONE
<brendan> or just |1
<thieusoai> ic
<thieusoai> I need to use the var uONE so |1 is not an option for me
<gildor> thieusoai: you need to go back to if !c = uONE then Printf.printf "ONE"
<thieusoai> yeh using if then else etc works fine
<gildor> so everything is fine ;-)
<mrvn> switch(x) { case uOne: ... case uTwo: ... } can be done with "where". Otherwise if it is just one case use if.
nb_ has joined #ocaml
<thieusoai> mrvn: I don't see the switch/where/case being used much in Ocaml -- do you have a reference where I can learn how to use them ?
<mrvn> thieusoai: The switch was C code.
<flux> thieusoai, the code in could be written in ocaml like: match xxx with | x where x = uOne -> .. | x where x = uTwo -> ..
<flux> I suppose that's what mrvn wrote also
<mrvn> flux: except it is "when" and not "where"
<flux> argh :)
<thieusoai> ah
<mrvn> always get that wrong too.
<flux> brendan confused me, succesfully ;-)
<thieusoai> no wonder it keeps saying syntax error where
<mrvn> yeah, xemacs also doesn't highlight "where" as keyword.
<brendan> oops :)
nb_ is now known as nb
<mrvn> I've used it a few times, but usualy with Foo (x,y) when x < z
nb has left #ocaml []
<thieusoai> thanks ! looks much cleaner than if then else for 20+ cases
ygrek has quit [Remote closed the connection]
Submarine has quit ["Leaving"]
<mrvn> Before I noticed "when" I really missed switch()
<thieusoai> the match works fine with me so far until today when I cannot pattern match with variables like uONE above
Modius has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
Associat0r has joined #ocaml
<thieusoai> how do I iter the list to find something then "break" when I find it ? for instance this code I wrote works fine but it iterates the entire list
<thieusoai> let f l = let v=ref 0 in List.iter(function (a,b)->(if b = 100 then v:=a))l; !v in f [(7,1);(2,100);(3,4)];;
<mrvn> thieusoai: option 1: raise an exception, option 2: write your own recursive function
<flux> v := fst (List.find (function (a, b) when b = 100 -> true | _ -> false))
<flux> plus the list argument
<mrvn> flux: still iterates the whole list
<flux> but I must notice that you seem to use a lot of mutable variables :)
<flux> mrvn, I would very much expect find to stop iterating on first find!
<mrvn> thieusoai: If you want to iter and pass along a result then fold instead.
<flux> fold doesn't really stop the iteration though
<mrvn> flux: doesn't it return a list of things it found? Or why the fst?
<flux> mrvn, no, it returns the first
<flux> mrvn, fst returns the first value of the pairs it's searching
<flux> fst isn't List.head..
<mrvn> ahh.
<mrvn> let find_first f not_found list = let rec loop = function [] -> not_found | x::xs when f x -> x | _::xs -> loop xs in loop list
<mrvn> fst (find_first (fun (a,b) -> b = 100) 0 [(7,1);(2,100);(3,4)]
<mrvn> or so.
albacker has quit [Read error: 113 (No route to host)]
Snark has quit ["Ex-Chat"]
bob` has joined #ocaml
<thieusoai> nice --- these higher order functions make the code very compact
bob` has quit [Remote closed the connection]
valross has joined #ocaml
slash_ has quit [Client Quit]
ttamttam has quit ["Leaving."]
thelema has quit [Remote closed the connection]
thelema has joined #ocaml
alp_ has quit [Client Quit]
munga_ has joined #ocaml
rwmjones_lptp has quit ["This computer has gone to sleep"]