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!)
felix^^ has joined #ocaml
<felix^^> Hi, I'm trying to use Gmetadom, and I'm getting an expression of type "Gdome.node option" -- what does this mean? A space separated type?
elq has quit []
dbueno has quit ["This computer has gone to sleep"]
ikaros has quit [Remote closed the connection]
<mbishop> could someone look at that and tell me why it keeps giving index out of bounds errors?
<pango> felix^^: parameterized type
<pango> mbishop: because total is an array of length 0 ? so total.(j) will break as soon as j > 0
<centrinia> Try : for j = 0 to i-1 do
<pango> mmmh in fact it will break, no matter the indice
<mbishop> Yeah, pretty sure I tried changing those up...in fact I didn't even use total before
<mbishop> but I've been trying anything I could think of
<centrinia> What does find_path do?
<centrinia> More importantly, this looks more like C than Ocaml.
<mbishop> Yeah, well I was converting from C to ocaml, basically heh
<mbishop> and find_path is supposed to find the path up the triangle that gives you the largest sum
<centrinia> I think ( for x = y to z do expr ) would be similar to for(x=y;x<=y;x++) { expr }
<centrinia> What is the formula for finding the value of a path?
jlouis has quit [Read error: 104 (Connection reset by peer)]
centrinia has quit ["Leaving"]
<pango> 1074, using path [75; 64; 82; 87; 82; 75; 73; 28; 83; 32; 91; 78; 58; 73; 93] ? :)
jlouis has joined #ocaml
<mbishop> 1074 is indeed the answer
<mbishop> how'd you get that? :(
<pango> I first converted your structure to a tree... much easier this way
<mbishop> Hmm, have the code? :o
<pango> I annotated above page
<mbishop> neat O_O
<mbishop> I'm gonna study this heh, thanks
<pango> np
<pango> it's probably not optimal, as many subtriangles must be reevaluated
<pango> but at least I got the answer ;)
seafood_ has joined #ocaml
<mbishop> Yeah, the problem comes when they give a 100 line triangle :/
<mbishop> with the smaller triangle, I have a method that is pretty fast
smimou has quit ["bli"]
<pango> new code, but I'm less confident over that one... would be easier with lists, I think (and you can remove the debugging' Printf ;) )
dbueno has joined #ocaml
<context> is there a way in ocaml to do like paramater defaults
<Jeff_123> parameter as in function arguments?
<context> yeah
<Jeff_123> two ways:
<Jeff_123> 1. make a new function that is the previous function with 1 or more arguments already applied
<Jeff_123> 2. use labeled arguments
<context> kk ill have to look that up
<Jeff_123> let add1 = List.map (fun x -> x+1)
bringert has quit [Read error: 110 (Connection timed out)]
<context> and whats the diff between 'function' and 'fun' :/
<felix^^> could someone point out to me why the commented fails to compile with the annotated error message, while the uncommented version works?
<context> gah, ocaml is gonna throw me through a loop
<context> is ocaml very good at / useful for doing event driven programming against many network sockets
<pango> mbishop: third solution using lists
mordaunt has joined #ocaml
<context> and why doesnt Unix.getpwnam work :/
<pango> it works, you just need to load, or link, unix.cma (bytecode) or unix.cmxa (native)
<pango> $ ocaml unix.cma
<pango> # Unix.getpwnam "bin" ;;
<pango> - : Unix.passwd_entry =
<pango> {Unix.pw_name = "bin"; Unix.pw_passwd = "x"; Unix.pw_uid = 2;
<pango> Unix.pw_gid = 2; Unix.pw_gecos = "bin"; Unix.pw_dir = "/bin";
<pango> Unix.pw_shell = "/bin/sh"}
<context> so open Unix;; isnt good ?
<context> # open Unix ;;
<context> # Unix.getpwnam "context" ;;
<context> Reference to undefined global `Unix'
<pango> that adds "Unix" to the list of namespaces the interpreter (or compiler) will look for identifiers
<context> oh .
<context> <-- still learning obviously :p
<pango> # open Unix ;;
<pango> # getpwnam "games" ;;
<pango> - : Unix.passwd_entry =
<pango> {pw_name = "games"; pw_passwd = "x"; pw_uid = 5; pw_gid = 60;
<pango> pw_gecos = "games"; pw_dir = "/usr/games"; pw_shell = "/bin/sh"}
<context> mmm, os x fails .
<context> nm, its just broken godi i guess
<context> pango: is there any generalized method of getting packages asside from godi
<context> macports 3.10 loads cma files fine, ocaml on godi is 3.09 and says dynamic loading isnt supported on os x
<pango> I'm using Debian, that comes with a good set of packaged ocaml libs
<pango> so I never used tried Godi
<context> kk
Mr_Awesome has joined #ocaml
yminsky has joined #ocaml
dbueno has quit ["Leaving"]
yminsky has quit []
buluca has quit [Read error: 113 (No route to host)]
seafood_ has quit []
mordaunt has quit [Read error: 104 (Connection reset by peer)]
<context> mm i think i need like an ocaml faq
<context> whats the diff between 'let f () = ...' and 'let f = function ...'
<tsuyoshi> felix^^: what is the type of Gdome.nodeList#item?
<tsuyoshi> let f () = and let f = function () -> are the same thing
<context> kk
<context> tsuyoshi: and is there a way to pass functions themselves as params or return values, or store them in a struct
<context> :x
<tsuyoshi> sure..
<tsuyoshi> functions are just regular variables
<tsuyoshi> let foo bar = bar 1 in foo (fun n -> n + 1)
<context> ahh gotcha
<context> yeah i need to start trying stuff out before asking questions for stuff like that
<tsuyoshi> operators are functions too.. if you put parentheses around them you can treat them like regular functions
<tsuyoshi> so with currying you can do that same example like
<tsuyoshi> let foo bar = bar 1 in foo ((+) 1)
<context> heh, i think the first one is a little mor readable :p
<context> oh now i get it
<context> how would you define unknown # of function arguements
<context> like printf does/can
<tsuyoshi> that is the only part of ocaml I don't understand yet
<context> haha
<tsuyoshi> the printf code makes no sense to me
<context> thats acceptable ;)
Yoric[DT] has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
felix^^ has quit [Remote closed the connection]
<flux> ooh, darcs 2.0pre1 is out
ttamttam has joined #ocaml
ertai has joined #ocaml
filp has joined #ocaml
<context> im a git man myself
<context> never touched darcs much :x
<flux> I've used darcs for small projects; I think my personal projects hit that category nicely ;)
<flux> perhaps I should switch a few older svn-repos to darcs too..
<flux> also my ~/.*-files are in darcs nowadays (they used to be in cvs, then I switched to subversion, now darcs)
<flux> darcs needs no configuration to talk about (it asks for your email address when you initialize a new repository) and pushing and pulling is a breeze.. also the cherry-picking of individual thunks while committing is nice, although I hear that's in its competitors also nowadays
<context> yeah i stated with svn, then hg for a couple weeks then git
<flux> perhaps the other dvcs-systems are just as nice, I haven't tried
<context> the idea of darcs sounds funny, the way it works :/
<context> meh ill save it for a boring sunday afternoon
sadmac has quit [Read error: 110 (Connection timed out)]
sadmac has joined #ocaml
__suri has quit []
ygrek_ has joined #ocaml
bringert has joined #ocaml
bringert has quit [Client Quit]
smimou has joined #ocaml
<lbc> why is ocamlc having problems with "/usr/lib/caml/config.h:140: error: parse error before "int64"" when working on a C source file that #includes mlvalues.h ?
<lbc> (I'm on a 32 bit 686)
<lbc> nevermind
<flux> what was the problem?
<lbc> I had the wrong config.h on my path
<lbc> the one for a native win32 ocamlc, but I was working in a cygwin environment
<Associat0r> question, will ocaml allow me todo pure functional programming like haskell also with monads and stuff
<Associat0r> I want to explore pure functional programming but don't want to have to learn haskell and ocaml at the same time
bongy has joined #ocaml
<flux> monadic programming is possible in ocaml, but it's not quite as easy as with haskell.
<flux> there are syntax extensions for writing monadic code
<flux> I'm sure a quick google will find a lot of related resources
<Associat0r> also is there any other thing that is missing?
<Associat0r> other than monads
<flux> type classes
<Associat0r> haskell has those?
<flux> yes
<Associat0r> that I can also simulate in ocaml?
<flux> module system has equivalent power, but you cannot emulate it syntax-wise
<Associat0r> ok thanks for advice man
<Associat0r> I will try haskell for a week first then and then switch to ocaml for real work
<Associat0r> it is just that I want to feel what pure functional looks like
<lbc> 'lo again ...
<lbc> ocamlopt is finding a "Corrupted compiled interface /usr/lib/ocaml/lablgtk2/gdk.cmi". lablgtk2 is pulled out of a cygwin repo. Can that be do to a version mismatch ?
<lbc> s/do/due/
ertai has quit [Read error: 110 (Connection timed out)]
asmanur has joined #ocaml
Proteus has joined #ocaml
bongy has quit ["Leaving"]
bringert has joined #ocaml
ertai has joined #ocaml
hkBst has joined #ocaml
bringert has quit []
rwmjones has joined #ocaml
jdh30 has joined #ocaml
Associat0r has quit []
Yoric[DT] has joined #ocaml
ikaros has joined #ocaml
bongy has joined #ocaml
jdh30 has quit ["using sirc version 2.211+KSIRC/1.3.12"]
ygrek_ has quit [Remote closed the connection]
Tetsuo has joined #ocaml
__suri has joined #ocaml
RobertFischer has joined #ocaml
RobertFischer has left #ocaml []
pango has quit [Remote closed the connection]
pango has joined #ocaml
marmottine has joined #ocaml
buluca has joined #ocaml
suppaman has joined #ocaml
ttamttam has left #ocaml []
<jonafan> ASDF
<jonafan> does anyone use the GTK bindings?
<Yoric[DT]> I've used them a bit.
<Yoric[DT]> Can't say I remember much.
<jonafan> well i just want to know generally how they work
<jonafan> you might remember enough to tell me that?
<Yoric[DT]> I remember that starting is tricky.
<Yoric[DT]> You need to understand the local GObject.
<Yoric[DT]> "local" as in "OCaml version of"
<Yoric[DT]> The good thing is that the library doesn't let you make much mistakes.
<jonafan> how do you get events?
<Yoric[DT]> Callbacks.
<jonafan> hmm
<Yoric[DT]> You attach them to objects using some method.
<jonafan> i'm trying to understand how to write a GUI as functionally as possible
<Yoric[DT]> Check Chris King's OCaml RT.
<Yoric[DT]> Functional Reactive toolkit.
<jonafan> if you must use callbacks, then the function that is being called by GTK must get its state from somewhere else while the function is running
<jonafan> okay
<jonafan> rad
kelaouchi has quit ["leaving"]
<jonafan> functional programming is rad
<Yoric[DT]> What do you mean ?
<jonafan> i just learned how to use monads and wrote some in ocaml a couple of days ago
<Yoric[DT]> I have only very little experience with monads.
<jonafan> monads are nifty but i guess you don't really need them in this language
<Yoric[DT]> At the moment, I'm playing with streams :)
<jonafan> lazy lists?
<jonafan> also very awesome
<Yoric[DT]> Nope, streams are destructive by opposition to lazy lists.
<jonafan> ohhhhh?
<Yoric[DT]> Note that I do find lazy lists very nice.
kelaouchi has joined #ocaml
<Yoric[DT]> I might add some syntax for these whenever I find time.
<jonafan> anyway, hooray for writing code that has no practical usage!
Associat0r has joined #ocaml
<Yoric[DT]> Yep :)
<jonafan> i also feel like i even understand OOP better even though i think it's 90% crap
ertai has quit [Read error: 110 (Connection timed out)]
<jonafan> the core of the OOP philosophy is to never return anything. it's getter functions, not setter functions in oop that are evil
<hkBst> Yoric[DT]: "streams are destructive by opposition to lazy lists"? Are you talking about memoization?
<Yoric[DT]> No, I'm talking about Stream.t .
<Yoric[DT]> Once you have read the first element of a stream, it disappears.
<Yoric[DT]> jonafan: Well, I have the feeling that people who come from functional programming tend to think that OOP solves all the wrong problems.
<hkBst> Yoric[DT]: ah, ports :)
<Yoric[DT]> Sounds like some bit of Haskell I never frequented.
<jonafan> if you walk down a lazy list with tail recursion, you lose references to the things you've already read, thus those nodes will disappear after being read
<Yoric[DT]> Indeed.
<hkBst> right, because no other references could possibly exist
<Yoric[DT]> With Stream.t, the first element always disappears when you move to the next element.
<Yoric[DT]> The main use is for recursive descent parsers.
<Yoric[DT]> Whenever I finish the first version of my parser, I might decide to make it use lazy lists instead.
<jonafan> \m/
<Yoric[DT]> Well, gottago.
<Yoric[DT]> Talk to you later.
<jonafan> bye
ygrek_ has joined #ocaml
buluca has quit ["Leaving."]
zmdkrbou_ has joined #ocaml
filp has quit ["Bye"]
Demitar has quit [Read error: 110 (Connection timed out)]
zmdkrbou has quit [Read error: 113 (No route to host)]
rwmjones has quit ["Closed connection"]
olleolleolle has joined #ocaml
bongy has quit ["Leaving"]
zmdkrbou_ is now known as zmdkrbou
ttamttam has joined #ocaml
olleolleolle has left #ocaml []
suppaman has quit [Read error: 104 (Connection reset by peer)]
suppaman has joined #ocaml
suppaman has quit [Read error: 104 (Connection reset by peer)]
suppaman has joined #ocaml
suppaman has quit [Read error: 104 (Connection reset by peer)]
suppaman has joined #ocaml
Snark has joined #ocaml
asmanur has quit [Remote closed the connection]
asmanur has joined #ocaml
madroach has joined #ocaml
nuncanada has joined #ocaml
asmanur has quit [Read error: 110 (Connection timed out)]
ertai has joined #ocaml
<Jeff_123> is there an ocaml zipper library for n-ary trees? So far all I can find is code for binary trees
buluca has joined #ocaml
suppaman has quit [Read error: 104 (Connection reset by peer)]
suppaman has joined #ocaml
suppaman has quit [Read error: 104 (Connection reset by peer)]
suppaman has joined #ocaml
ecc has joined #ocaml
asmanur has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
<Jeff_123> nm I found one
bongy has joined #ocaml
asmanur has quit [Remote closed the connection]
<Yoric[DT]> Yes, I can now build streams from lists -- with comprehension.
<Jeff_123> is that the camlp4 stuff you've been working on?
<Yoric[DT]> Yep.
<Jeff_123> how many bytes of camlp4 language does it take to implement it?
<Yoric[DT]> About 30k.
<Yoric[DT]> But they add several features.
<Yoric[DT]> * a new "for" loop
<Yoric[DT]> (well, not very new, it's an extension of that of the OCaml Tutorial)
<Yoric[DT]> * array ranges
<Yoric[DT]> * list ranges and comprehension
<Yoric[DT]> * stream ranges and comprehension
<Yoric[DT]> * "cross-comprehension" from lists to streams
<Yoric[DT]> (or from arrays to streams)
<Jeff_123> sounds pretty wild
<Yoric[DT]> I'm having fun :)
Snark has quit ["Quitte"]
ttamttam has left #ocaml []
Jeff_123 has quit ["Leaving."]
nuncanada has quit ["Leaving"]
<mbishop> list ranges eh? neat :)
<mbishop> I hate having to write my own
olleolleolle has joined #ocaml
marmottine has quit ["Quitte"]
context has quit [Remote closed the connection]
bongy has quit ["Leaving"]
context has joined #ocaml
olleolleolle has left #ocaml []
Jeff_123 has joined #ocaml
kelaouch1 has joined #ocaml
Tetsuo has quit ["Leaving"]
Jeff_123 has quit [Read error: 104 (Connection reset by peer)]
Jeff_123 has joined #ocaml
pippijn_ has joined #ocaml
pippijn has quit [Read error: 104 (Connection reset by peer)]
mbishop has quit ["Konversation terminated!"]
mbishop has joined #ocaml
suppaman has quit ["all your bye are belong to us"]
<Yoric[DT]> If anyone's interested, the samples for my syntax extensions are there: http://pastebin.mozilla.org/262773 .
Demitar has joined #ocaml
<Jeff_123> yes I'm VERY interested!
<hcarty> Yoric[DT]: Looks very nice
<Yoric[DT]> thanks
<hcarty> Do ranges and comprehensions work together?
<Yoric[DT]> Yes.
<hcarty> Then doubly nice :-)
<Yoric[DT]> :)
<Yoric[DT]> I'll try and clean-up the code this week.
<Jeff_123> I definetly like the looks of it
<Yoric[DT]> I've optimized arrays to try and make sure that ranges don't make too much of a mess.
<Yoric[DT]> i.e. [|1..5|] is computed during compilation
<Yoric[DT]> but [|0+1 .. 5|] has to be deferred to execution
<Jeff_123> too bad it probably conflicts with the already existing list comprehension syntax extentsion, but fram what I've seen it's not terribly powerful anyway.
<Jeff_123> I mean the already existing one isn't...
<Yoric[DT]> Actually, I use the same syntax (and I replace their rules, so it shouldn't be a problem).
<Yoric[DT]> Anyway, gottago.
<Jeff_123> oh that's cool, so I could mix your expentension with their [ x | blah ] syntax? That's cool.
<Jeff_123> ok see you!
<Yoric[DT]> Good night everyone.
ertai has quit [Read error: 110 (Connection timed out)]
Yoric[DT] has quit ["Ex-Chat"]
buluca has joined #ocaml
gim has quit [Read error: 110 (Connection timed out)]