gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.1 http://bit.ly/nNVIVH
lopex has quit []
wtetzner has quit [Remote host closed the connection]
struktured has quit [Ping timeout: 244 seconds]
schme has quit [Ping timeout: 260 seconds]
joewilliams_away is now known as joewilliams
struktured has joined #ocaml
struktured has quit [Read error: Connection reset by peer]
destrius has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
Boscop has quit [Ping timeout: 258 seconds]
oriba has quit [Quit: oriba]
everyonemines has quit [Quit: Leaving.]
dnolen has joined #ocaml
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
dnolen has quit [Client Quit]
wtetzner has joined #ocaml
joewilliams is now known as joewilliams_away
RafeKettler has quit [Quit: RafeKettler]
joewilliams_away is now known as joewilliams
wtetzner has quit [Remote host closed the connection]
wtetzner has joined #ocaml
RafeKettler has joined #ocaml
RafeKettler has quit [Client Quit]
The_third_man has joined #ocaml
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
joewilliams is now known as joewilliams_away
junsuijin1 has joined #ocaml
junsuijin1 has quit [Client Quit]
EmmanuelOga has joined #ocaml
mmu_man has quit [Ping timeout: 260 seconds]
struktured has joined #ocaml
emmanuelux has quit [Ping timeout: 244 seconds]
watr is now known as rntz
Tianon has quit [Ping timeout: 240 seconds]
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
Associat0r has joined #ocaml
arubin has quit [Quit: arubin]
dcolish has quit [Quit: Coyote finally caught me]
redsteg has quit [Ping timeout: 240 seconds]
redsteg has joined #ocaml
jimmyrcom has quit [Ping timeout: 248 seconds]
EmmanuelOga has quit [Ping timeout: 255 seconds]
ulfdoz has joined #ocaml
hto has joined #ocaml
ulfdoz has quit [Ping timeout: 240 seconds]
schme has joined #ocaml
schme has quit [Changing host]
schme has joined #ocaml
schme has quit [Ping timeout: 244 seconds]
dcolish has joined #ocaml
schme has joined #ocaml
schme has quit [Changing host]
schme has joined #ocaml
ygrek has joined #ocaml
schme has quit [Ping timeout: 248 seconds]
schme has joined #ocaml
Cyanure has joined #ocaml
fraggle_ has quit [Ping timeout: 260 seconds]
Snark has joined #ocaml
Kakadu has joined #ocaml
edwin has joined #ocaml
ttamttam has joined #ocaml
schme has quit [Ping timeout: 260 seconds]
schme has joined #ocaml
schme has quit [Changing host]
schme has joined #ocaml
schme has quit [Ping timeout: 260 seconds]
schme has joined #ocaml
schme has quit [Changing host]
schme has joined #ocaml
ygrek has quit [Ping timeout: 248 seconds]
maufred has joined #ocaml
mmu_man has joined #ocaml
surikator has joined #ocaml
avsm has joined #ocaml
drake01 has joined #ocaml
drake01 has quit [Max SendQ exceeded]
drake01 has joined #ocaml
superbobry has joined #ocaml
superbobry has quit [Quit: Leaving.]
drake01 is now known as p
p is now known as Guest45978
ikaros has joined #ocaml
Guest45978 has quit [Quit: Ex-Chat]
drake01 has joined #ocaml
avsm has quit [Quit: Leaving.]
drake01 has quit [Ping timeout: 248 seconds]
Associat0r has quit [Ping timeout: 252 seconds]
wishi has quit [Ping timeout: 260 seconds]
ztfw has joined #ocaml
wishi has joined #ocaml
lopex has joined #ocaml
wishi has quit [Ping timeout: 260 seconds]
drake01 has joined #ocaml
drake01 has quit [Changing host]
drake01 has joined #ocaml
wishi has joined #ocaml
drake01 has quit [Client Quit]
wishi has quit [Ping timeout: 260 seconds]
_andre has joined #ocaml
superbobry has joined #ocaml
<superbobry> thelema: hello :)
wishi has joined #ocaml
destrius has quit [Quit: Leaving.]
wishi has quit [Remote host closed the connection]
wishi has joined #ocaml
surikator has quit [Quit: Computer is sleeping. I'm probably not.]
surikator has joined #ocaml
surikator has quit [Client Quit]
emmanuelux has joined #ocaml
superbobry has left #ocaml []
sadgur has joined #ocaml
ygrek has joined #ocaml
ygrek has quit [Ping timeout: 248 seconds]
larhat has joined #ocaml
sadgur has quit [Quit: WeeChat 0.3.5]
hnrgrgr has quit [Remote host closed the connection]
Cyanure has quit [Remote host closed the connection]
avsm has joined #ocaml
avsm1 has joined #ocaml
avsm has quit [Read error: Connection reset by peer]
Cyanure has joined #ocaml
iris1 has quit [Ping timeout: 260 seconds]
jimmyrcom has joined #ocaml
iris1 has joined #ocaml
oriba has joined #ocaml
hnrgrgr has joined #ocaml
Anarchos has joined #ocaml
surikator has joined #ocaml
joewilliams_away is now known as joewilliams
EmmanuelOga has joined #ocaml
joewilliams is now known as joewilliams_away
lopex has quit [Ping timeout: 265 seconds]
lopex has joined #ocaml
fnltslpk has quit [Ping timeout: 265 seconds]
oriba is now known as oribot
oribot is now known as oriba
Modius has quit [Quit: "Object-oriented design" is an oxymoron]
rixed has joined #ocaml
surikator has quit [Ping timeout: 258 seconds]
Kakadu has quit [Quit: Page closed]
jimmyrcom has quit [Ping timeout: 252 seconds]
ztfw has quit [Ping timeout: 260 seconds]
mehdid has quit [Ping timeout: 276 seconds]
surikator has joined #ocaml
joewilliams_away is now known as joewilliams
jimmyrcom has joined #ocaml
Cyanure has quit [Ping timeout: 244 seconds]
joewilliams is now known as joewilliams_away
sepp2k has joined #ocaml
mehdid has joined #ocaml
Modius has joined #ocaml
lopex has quit []
ulfdoz has joined #ocaml
ztfw has joined #ocaml
surikator has quit [Quit: Computer is sleeping. I'm probably not.]
mnabil has joined #ocaml
ulfdoz_ has joined #ocaml
avsm1 has quit [Quit: Leaving.]
lopex has joined #ocaml
ulfdoz has quit [Ping timeout: 245 seconds]
ulfdoz_ is now known as ulfdoz
mnabil has quit [Ping timeout: 248 seconds]
avsm has joined #ocaml
larhat has quit [Quit: Leaving.]
Boscop has joined #ocaml
joewilliams_away is now known as joewilliams
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
fraggle_laptop has joined #ocaml
fraggle_laptop has quit [Client Quit]
fraggle_laptop has joined #ocaml
joewilliams is now known as joewilliams_away
fschwidom has joined #ocaml
fraggle_laptop has quit [Remote host closed the connection]
joewilliams_away is now known as joewilliams
<smango> is there any built in way to sort a list of tuples according to the first component?
fraggle_laptop has joined #ocaml
<_habnabit> no
<_habnabit> here's some good functions to define for this kind of thing, though:
<_habnabit> let on f g a b = g (f a) (f b)
<_habnabit> let comparing f a b = compare (f a) (f b)
<_habnabit> then you can say (comparing fst) or (on fst IntSet.compare)
<smango> alright, thanks :)
<adrien> hmmm, List.sort (fun a b -> compare (fst a) (fst b)) your_list
<_habnabit> it's a common-enough thing that I'd recommend throwing `comparing` somewhere
<Anarchos> adrien i don't rely on List.sort because it is not based on smoothsort of Djikstra :)
<Qrntzz> the compare function from the standard library can compare tuples by their first element on it's own
joewilliams is now known as joewilliams_away
<adrien> write your own :P
<adrien> actually Qrntzz is right: the default compare would do it
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
Anarchos has quit [Quit: time to lunch]
sebz has joined #ocaml
avsm has quit [Quit: Leaving.]
Sysop_fb has joined #ocaml
joewilliams_away is now known as joewilliams
surikator has joined #ocaml
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
joewilliams is now known as joewilliams_away
Modius_ has joined #ocaml
Modius_ has quit [Read error: Connection reset by peer]
sebz has quit [Quit: Computer has gone to sleep.]
ttamttam has quit [Quit: Leaving.]
sepp2k has quit [Remote host closed the connection]
joewilliams_away is now known as joewilliams
hnrgrgr has quit [Ping timeout: 276 seconds]
hnrgrgr has joined #ocaml
lopex has quit []
lopex has joined #ocaml
fschwidom has quit [Remote host closed the connection]
sepp2k has joined #ocaml
sepp2k has quit [Ping timeout: 240 seconds]
g0dmoney- has quit [Ping timeout: 244 seconds]
Anarchos has joined #ocaml
joewilliams is now known as joewilliams_away
<jonafan> does smoothsort typically outperform quicksort?
<jonafan> looking at it, the cache behavior can't be that great
sepp2k has joined #ocaml
<_habnabit> we should really all be using timsort anyway
Sebben has joined #ocaml
<Sebben> Good afternoon! Is there a function in the standard library that allows me to convert from a char list to a string? I have been looking and looking, and can't find anything in google either. Thanks!
<adrien> in the stdlib? I don't know but you can easily count the length of the list, create a string, and set it
<adrien> or maybe through Buffer but it's still be more costly
<Sebben> adrien: thanks. Yes, can definitely make it myself, but just got confused that it didn't already exist.
<bitbckt> oof. yeah. Buffer.add_char + Buffer.contents would be pricey.
<jonafan> this is not the last time you'll be shocked that the std library doesn't include something
<bitbckt> I don't think there's anything matching char list -> string in stdlib.
<Anarchos> Sebben List.fold_left
<Sebben> jonafan: just getting started, and I am used to the standard libs containing most things. Is going to be an interesting learning experience
<jonafan> i still haven't gotten over the lack of functions for dealing with binary data
<adrien> Anarchos: List.fold_left is going to be horribly costly
<Sebben> Anarchos: List.fold_left starting with a string of the right size and then setting the character values?
<adrien> Sebben: huge stdlibs have the downside that you can't remember what they have ;-)
<Anarchos> adrien sure but only one line to write, i am lazy to do running time optimization :)
<Sebben> adrien: hehe, that's true
<adrien> Anarchos: too many allocations: that one is quite ugly imho
<Sebben> adrien: while would List.fold_left be inefficient?
<Anarchos> Sebben no, just add chars with (^) and string_of_char which should exist somewhere
<Anarchos> Sebben because it is not tail recursive, so much data lost on stack
<Sebben> Anarchos: aha, sure. In my case that is something I can live with. Really short strings.
<adrien> Sebben: if you use (^) for concatenation of strings all the time, you need to allocate new strings each time
<Sebben> adrien: ok, good point. I think I'll create a string of the right length and then set the characters one by one
<adrien> so, you'd need to allocate a string of n elements, then n+1, then n+2... making it O(n^2) [ n*(n+1)/2) ]
<bitbckt> I don't think there's a string_of_char, either.
<bitbckt> Char.escaped, I guess...
<adrien> the annoying bit is that you don't have List.iteri yet, it's in 3.13's stdlib however (not out yet)
<Anarchos> bitbckt Char.to_string ?
<adrien> String.make
<bitbckt> Anarchos: I don't have that.
<bitbckt> You'd have to use... yeah.
<bitbckt> what adrien said.
<adrien> let s = String.make 1 your_char in ...
<Sebben> you guys are awesome :) thanks for all the help!
<bitbckt> then use String.set to swap chars.
<jonafan> or s.[i] <-- character
<jonafan> er <-
<bitbckt> same thing.
<jonafan> got carried away
<bitbckt> that hyphen is an alluring beast.
<adrien> yup, it's the best way if your string has been allocated
Cyanure has joined #ocaml
<Sebben> Ok, ended up with the following. I am a OCaml beginner, so comments more than welcome!
<Sebben> let string_of_chars chars =
<Sebben> let string = String.create (List.length(chars)) in
<Sebben> let _ = List.fold_left (fun position c -> String.set string position c; position + 1) 0 chars in
<Sebben> string
<Sebben> oh, and code doesn't paste well. I'll provide a link instead
<adrien> style: List.length chars
<adrien> no parens but spaces
<Sebben> adrien: great, thanks. I'll fix
<adrien> (String.set s p c) is as easily written as s.[p] <- c
zsparks has left #ocaml []
<Sebben> adrien: true. I'll change that too
<adrien> and does it work?
<adrien> also, I'd probably: ignore (List.fold_left .....);
<adrien> but I guess not everyone here would
<thelema> adrien: List.iteri?
<thelema> for i = 0 to List.length chars do ... odne
<adrien> commit d53838a075fbf528fbe340671c4da0c73570e4e1
<adrien> Author: frisch <frisch@f963ae5c-01c2-4b8c-9fe0-0dff7051ff02>
<adrien> Date: Fri Nov 5 08:10:59 2010 +0000
<Sebben> adrien: what is ignore? Does it just ignore the output? allowing me to skip the let _ = part?
<Anarchos> Sebben yes
<thelema> Sebben: can you use a for loop?
<Anarchos> let ignore x = ();;
<adrien> (ignore foo) will ... ignore foo (it always returns "unit")
<adrien> thelema: you need to move inside the list however
Associat0r has joined #ocaml
Associat0r has quit [Changing host]
Associat0r has joined #ocaml
<Sebben> thelema: yes, I guess I could do that too.
<thelema> adrien: ah, you're right. that would require a ref to efficiently iterate through the list
<adrien> Sebben: btw, where is your list of chars from,
<adrien> ?
<Sebben> thelema: do you think that is better? and if so, why? Would be interesting to know!
<Sebben> adrien: hehe, I just developed a rather stupid trie and now I am iterating over the trie collecting different stats and building up words that I have spelled out in it
<thelema> or just a hand-written recursive function `let rec loop i = function [] -> () | h::t -> s.[i] <- h; loop (i+1) t`
<thelema> although this question seems homeworkish, as there's already String.implode in batteries
<adrien> Sebben: I was wondering if it were not coming from some imperative source, in which case a Queue would have been a better fit than a list
<adrien> so, most probably no
<thelema> Sebben: the best is the hand written tail recursive loop
<Sebben> thelema: well, absolutely not homework. Just a fun little side project. Need to learn OCaml for some real work I will be starting soon, so just fooling around for the moment
<thelema> in terms of performance
<adrien> do we have a beginner guide to ocaml, something to intro to the ecosystem? (somehow, I think I've already asked the question not so long ago)
<Sebben> thelema: well, in this case it absolutely not performance critical, and the List.fold_left reads so nice and cleanly
<thelema> Sebben: I dislike the use of fold left for a side effect
<thelema> you really want List.iteri, which isn't in stdlib, but is in batteries (and I'm sure core)
<adrien> I have to say I had issues with "let _ = List.fold_left ..."; seemed wrong at first
<adrien> (I think I have the same in some of my code somewhere however)
<thelema> Fundamentally, you're not performing a fold, accumulating a value as the result of repeated application of a function to successive list values
<thelema> you're iterating through the list and happen to need your position in the list as well
<thelema> which is List.iteri
<Sebben> thelema: Ok, cool, I'll look into the batteries. Thanks
<jonafan> i would definitely recommend using batteries or core
<Sebben> jonafan: thanks, will do!
<jonafan> it's just that the standard library is such a joke
Cyanure has quit [Remote host closed the connection]
<thelema> jonafan: it's quite good for an academic language, but pretty small compared to... well, java. or .net
<adrien> I'm lost in these stdlibs
<adrien> for smaller functions, I find it easier and faster to code them myself than to try to remember a _huge_ list of functions
<jonafan> not having a decent standard library holds ocaml back
<adrien> for bigger ones, I look them up
<jonafan> okay adrien, but what if you get in a crazy situation where you need to read a binary file
<adrien> bitstring, with the associated pa_
<thelema> adrien: granted - this is a failure of documentation accessibility
<jonafan> or deal with dates/times
<thelema> jonafan: Calendar
<adrien> thelema: things could be better but I don't think it's a _huge_ issue
<jonafan> it sucks that you have to find libraries for this kind of trivial stuff
<thelema> jonafan: oasis-db is working on this problem, with odb for installation.
<adrien> JDK is 223MB on this computer and eclipse is bringing some more things (for swt)
<adrien> my /opt/ocaml is 876MB and it has a _lot_ of libraries in it
<adrien> as for an stdlib that would include the functionalities of Calendar and Bitstring, that'd be a pretty big library: bigger than needed for an stdlib
<jonafan> seriously? it's like half a megabyte
<thelema> adrien: wow, I didn't realize there was that much ocaml available...
<thelema> That includes a lot of bootstrapping the ocaml compiler, no?
<jonafan> why include the unix module or threads if we're concerned about all this out of control bloat in the standard library
<adrien> thelema: "ocamlfind list" has 239 lines (including subpackages)
<adrien> here
Snark has quit [Quit: Quitte]
<adrien> 137 unique ones but that still includes a different lib for each ocamlnet module (and pxp)
_andre has quit [Quit: leaving]
fraggle_ has joined #ocaml
surikator has quit [Quit: Scientific discovery is just maximal compression of strings. Nothing more, nothing less.]
joewilliams_away is now known as joewilliams
Sebben has quit [Quit: Sebben]
ztfw has quit [Ping timeout: 252 seconds]
g0dmoney- has joined #ocaml
edwin has quit [Remote host closed the connection]
joewilliams is now known as joewilliams_away
sepp2k has quit [Remote host closed the connection]
oriba has quit [Quit: oriba]
ikaros has quit [Quit: Ex-Chat]
bobry has quit [Ping timeout: 260 seconds]
bobry has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
fraggle_laptop has quit [Ping timeout: 240 seconds]
sebz has joined #ocaml
TheSeparateFirst has joined #ocaml
bobry has quit [Ping timeout: 255 seconds]
everyonemines has joined #ocaml
hyperboreean has quit [Ping timeout: 252 seconds]
hyperboreean has joined #ocaml
mmu_man has quit [Ping timeout: 258 seconds]
wtetzner has quit [Remote host closed the connection]
Amorphous has quit [Ping timeout: 255 seconds]
bobry has joined #ocaml
Amorphous has joined #ocaml
_habnabit has quit [Quit: ZNC - http://znc.sourceforge.net]
emmanuelux has quit [Ping timeout: 240 seconds]
wtetzner has joined #ocaml
avsm has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
dnolen has joined #ocaml
everyonemines has quit [Quit: Leaving.]