mbishop changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab Ocaml 3.10.0 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
pango has quit [Remote closed the connection]
pango has joined #ocaml
bzzbzz has joined #ocaml
bluestorm_ has quit ["Konversation terminated!"]
Demitar has quit [Read error: 110 (Connection timed out)]
slipstream has joined #ocaml
EliasAmaral has joined #ocaml
slipstream-- has quit [Read error: 110 (Connection timed out)]
slipstream-- has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
shawn` has quit ["This computer has gone to sleep"]
slipstream-- is now known as slipstream
shawn` has joined #ocaml
brothers has joined #ocaml
yminsky has joined #ocaml
minciue has quit [Read error: 113 (No route to host)]
thorat has quit ["leaving"]
noteventime has quit ["Leaving"]
yminsky has quit []
m3ga has joined #ocaml
b00t has joined #ocaml
shawn` has quit ["This computer has gone to sleep"]
darinwm has joined #ocaml
m3ga has quit ["disappearing into the sunset"]
darinwm has left #ocaml []
bluestorm_ has joined #ocaml
piggybox_ has joined #ocaml
piggybox has quit [Connection timed out]
minciue has joined #ocaml
kelaouch1 has quit [Read error: 104 (Connection reset by peer)]
m3ga has joined #ocaml
m3ga has quit [Read error: 104 (Connection reset by peer)]
piggybox_ is now known as piggybox
Smerdyakov has quit ["Leaving"]
Demitar has joined #ocaml
ygrek has joined #ocaml
rwmjones_ has joined #ocaml
fy__ has quit [Read error: 110 (Connection timed out)]
love-pingoo has joined #ocaml
lde has joined #ocaml
slipstream has quit [Read error: 104 (Connection reset by peer)]
slipstream has joined #ocaml
Mr_Awesome has quit ["time to impregnate a moth"]
love-pingoo has quit ["Connection reset by pear"]
ygrek has quit [Remote closed the connection]
ygrek has joined #ocaml
pantsd has quit [Read error: 110 (Connection timed out)]
m3ga has joined #ocaml
m3ga has quit [Read error: 104 (Connection reset by peer)]
leo037 has joined #ocaml
yminsky has joined #ocaml
yminsky has quit [Read error: 104 (Connection reset by peer)]
yminsky has joined #ocaml
yminsky has quit [Client Quit]
noteventime has joined #ocaml
pantsd has joined #ocaml
yminsky has joined #ocaml
ygrek has quit [Remote closed the connection]
ygrek has joined #ocaml
ore05048 has joined #ocaml
<ore05048> hey noteventime
buluca has quit [Read error: 113 (No route to host)]
<noteventime> ore05048: Hello :-)
<ore05048> cna you pm me
love-pingoo has joined #ocaml
krumms has joined #ocaml
ore05048 has quit [Read error: 110 (Connection timed out)]
<krumms> Can anybody simplify the code in inv_chord_map: http://pastebin.com/d30200980 ... ?
<krumms> effectively want to translate chord_map such that for an entry (n, [k1; k2; k3]), we generate entries in the resulting list that look like: [k1, n; k2, n; k3, n]
<krumms> I'm a little disgusted that my code to generate that table of reverse mappings is longer than what it would be if I just copied it over by hand :)
<krumms> but I'm relatively new to ocaml ... not entirely sure what to try next
<flux> krumms, atleast the pattern let rec .. chords = .. let a = List.hd chords.. let b = List.tl chords.. could be replaced with let rec .. (a::b) ..
<krumms> flux, that's a start - thank you :)
<flux> so that'll cut 4 lines and a useless name
<flux> also you appear to use a non-tail-recursion elimination pattern
<flux> so for better efficiency you could replace the let new_result = a @ [b] with b::a and in the [] -> new_result do [] -> List.rev new_result
<flux> hm, infact, isn't chord_sequence a lot like List.map?
<flux> List.map (fun value -> (chord, value)) chords
<flux> chord_sequence fails with an empty list anyway; the match on empty list should be done earlier
<flux> construct_chord_map appears to follow the same pattern
<krumms> thanks heaps flux, post a new version shortly
<bluestorm_> hm
<bluestorm_> so you choosed a guitar program as a pratical topic ?
<bluestorm_> hm flux
yminsky has quit []
<bluestorm_> « let rec .. (a::b) .. »
<krumms> bluestorm_: nope, this is a personal project :)
<bluestorm_> aren't those kind of non-exhaustive matches forbidden by the revised syntax for example ?
<bluestorm_> i like to write let [a';b';c';d'] = List.map foo [a; b; c; d] very much, but i feel guilty at the same time
<flux> bluestorm_, well, the function did unconditional List.tl anyway
<flux> but yeah, the compiler does produce diagnostics on that case
<flux> sometimes it annoys me :)
<flux> but if the functions can be replaced with a List.map, all the better..
<bluestorm_> my problem is not really warnings (i guess they might be turned off), but the feeling i may be doing something semantically dubious ^^
<bluestorm_> krumms:
<bluestorm_> [a; b; c; d] very much, but i feel guilty at the same time
<bluestorm_> [15:11:59] <flux> bluestorm_, well, the function did unconditional List
<bluestorm_> hm
<bluestorm_> not this one :-°
<bluestorm_> # let inv chords = List.flatten (List.map (fun (num, notes) -> List.map (fun note -> note, num) notes) chords);;
<bluestorm_> hey
<bluestorm_> let's try xavierbot
<bluestorm_> let inv chords = List.flatten (List.map (fun (num, notes) -> List.map (fun note -> note, num) notes) chords);;
<xavierbot> val inv : ('a * 'b list) list -> ('b * 'a) list = <fun>
<bluestorm_> inv [1, ["A"]; 2, ["B"; "A#"]];;
<xavierbot> - : (string * int) list = [("A", 1); ("B", 2); ("A#", 2)]
<bluestorm_> is that correct ?
<bluestorm_> (Bb)
<krumms> yep, spot on. Exactly what I was after
<krumms> thanks bluestorm_ ... couldn't work out how I was to use List.map to generate N results for a single input. Seems I was looking for flatten.
<bluestorm_> don't hesitate to go wandering in http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html
<bluestorm_> hm
buluca has joined #ocaml
<bluestorm_> if you're not comfortable with recursion and pattern-matching, it may be a very good training to recode some of these functions
<krumms> oh I was looking at the docs, was just a bit hard to get my head around what some of the functions actually *do* at this hour :)
<bluestorm_> length, append, iter, map, fold_*, and rev for example
<bluestorm_> hm
<bluestorm_> coding them might be a good way to figure that out
<krumms> yeah cheers :) might do that over the coming week
<bluestorm_> moreover, map and rev will introduce you to some non-trivial ocaml ways of doing things
<krumms> sounds great bluestorm_. I'll be sure to run my crappy implementations by you as I cobble them together :)
<bluestorm_> hm
<bluestorm_> you'll see, map is a really perverse one :-°
<krumms> haha
<krumms> look forward to it :)
<krumms> but for now I've got to go crawl into bed
<krumms> night all!
<krumms> thanks again :)
krumms is now known as krumms-ZZZ
<pango> let inv2 chords = List.fold_left (fun acc (num, notes) -> List.fold_left (fun acc note -> (num, note) :: acc) acc notes) [] chords ;;
<xavierbot> val inv2 : ('a * 'b list) list -> ('a * 'b) list = <fun>
<pango> removes flattening step by folding results all along...
<pango> inv2 [1, ["A"]; 2, ["B"; "A#"]];;
<xavierbot> - : (int * string) list = [(2, "A#"); (2, "B"); (1, "A")]
<pango> mmh. replace (num, note) with (note, num)
<pango> (* like this *) let inv2 chords = List.fold_left (fun acc (num, notes) -> List.fold_left (fun acc note -> (note, num) :: acc) acc notes) [] chords ;;
<xavierbot> val inv2 : ('a * 'b list) list -> ('b * 'a) list = <fun>
<bluestorm_> pango: i find the flatten version more straightforward
<bluestorm_> and GHC could optimise it away :-°
<flux> pango, wouldn't you like to use fold_right to preserve the order
<flux> anyway, I would prefer the version with flatten, IMO it's easier to see what's going on. even some of the intermediate functions could be a good idea.
<pango> depends whether the order matter. List.fold_left in tailrec
<pango> s/in/is/
<bluestorm_> i don't think the order matters here
<bluestorm_> as he seems to consider a num <-> chord relation
b00t has quit ["Leaving"]
<flux> the original code seemed to go into some lengths to maintain the order
<flux> (the list concatenation namely)
rwmjones_ has quit ["This computer has gone to sleep"]
pango has quit [Remote closed the connection]
pango has joined #ocaml
mnemonic has quit ["leaving"]
pantsd has quit ["Leaving."]
Smerdyakov has joined #ocaml
yminsky has joined #ocaml
fy__ has joined #ocaml
yminsky has quit []
love-pingoo has quit ["Connection reset by pear"]
noteventime has quit [Remote closed the connection]
noteventime has joined #ocaml
jlouis_ has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
Mr_Awesome has joined #ocaml
rwmjones_ has joined #ocaml
rwmjones_ has quit [Client Quit]
brothers has quit [Read error: 104 (Connection reset by peer)]
krumms_ has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
krumms-ZZZ has quit [Read error: 110 (Connection timed out)]
piggybox_ has joined #ocaml
minciue has quit [Read error: 110 (Connection timed out)]
piggybox has quit [Nick collision from services.]
piggybox_ is now known as piggybox
slipstream-- has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
minciue has joined #ocaml
noteventime has quit [Remote closed the connection]
noteventime has joined #ocaml
brothers has joined #ocaml
ygrek has quit ["Leaving"]
seafoodX has joined #ocaml
_blackdog has joined #ocaml
_blackdog has left #ocaml []
buluca has joined #ocaml
mnemonic has joined #ocaml
qwwqe has joined #ocaml
jlouis_ has quit [Remote closed the connection]
jlouis has joined #ocaml
smimou has joined #ocaml
buluca has quit ["Leaving."]
seafoodX has quit []
buluca has joined #ocaml
kig has quit [Read error: 110 (Connection timed out)]
leo037 has quit ["c'est pas faux"]
smimou has quit ["bli"]
fax has joined #ocaml
<fax> hello
<Mr_Awesome> hi
krumms has joined #ocaml
<fax> I was wondering what/if anything people use to write GUI programs on mac with Ocaml?
<Mr_Awesome> well, could use tcl/tk
<fax> you would embed tcl in Ocaml and then use the tk lib from in that way?
<Smerdyakov> Isn't there already an OCaml library that figures that out in its implementation, freeing you from deciding?
<fax> I dont see anything here http://caml.inria.fr/pub/old_caml_site/humps/caml_Graphics_and_GUI_tool_kits.html which fits that description
<bluestorm_> hm
<krumms> fax: labltk
<bluestorm_> LablGTK would work on mac
<bluestorm_> and it's more advanced than Tk
<bluestorm_> fax: otherwise you could considerind using a OCaml backend and some other langage as a GUI frontend
<fax> what do you mean OCaml backend?
<bluestorm_> (i know there are working Python and Ruby binding, for example, altought i don't think Obj-C is available)
<bluestorm_> hm
<fax> like embed OCaml in another program?
<bluestorm_> hm
<bluestorm_> i mean, most program are a boring GUI stuff, and some interseting computations in the inside
<bluestorm_> you can use OCaml for the real stuff, and use a GUI stack in a different language
<fax> ah yeah
<fax> but how could you do that?
<bluestorm_> (wheter OCaml in the GUI language or the language is embedded in OCaml is a different question)
<bluestorm_> hm
<Smerdyakov> fax, why are you asking? Why not use labltk or lablgtk?
<bluestorm_> first of all i'd advice you to try lablGTK
<fax> just interested in what he had to say, I think I will try lablGTK as well
<bluestorm_> hm, there are some Python and Ruby bindings for OCaml around
<mbishop> lablgtk is pretty nice, which the documentation was finished though
<bluestorm_> (and C, of course, but i'm not sure C is the best choice for GUI-level stuff)
<mbishop> but really you can use regular gtk docs
* mbishop shrugs
<Smerdyakov> fax, it's not a deep suggestion. You would just be interfacing separate processes via command line interaction, most likely.
<fax> ah I see
<fax> des anyone know where the documentaiton for an Ocaml interface to C is?
<fax> or if it has a particular name
<fax> thank you
<bluestorm_> hm
<bluestorm_> you might like this one too : http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora112.html
<bluestorm_> it's older (but i don't think a lot of things changed since), but maybe more "user-friendly"
<bluestorm_> (and less complete, of course)
<fax> I would like one which can call C functions which pass/return structs a values
<bluestorm_> both these document describe the official, out-of-box Caml-to-C interface
<fax> I can't tell from this documentation.. anyone know if the C interface lets you call C functions which take as parameters or return structs as values?
<fax> in Ocaml how can you call the stdlib function div_t div(int num, int denom); for example?