flux changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab OCaml 3.10.2 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
Jeff_123 has joined #ocaml
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
TypedLambda has quit ["Leaving..."]
seafood_ has joined #ocaml
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood_ has quit []
ThanhVu_Nguyen has joined #ocaml
tvn1981a has quit ["ChatZilla 0.9.83 [Firefox 3.0.1/2008070206]"]
ThanhVu_Nguyen is now known as tvn1981a
coucou747 has quit ["bye ca veut dire tchao en anglais"]
coucou747 has joined #ocaml
seafood has joined #ocaml
seafood has quit [Connection reset by peer]
seafood has joined #ocaml
MelanomaSky has joined #ocaml
<MelanomaSky> I'd like to convert a given type to a string. Say "type t = FOO | BAR". Is there a better way than a function like 'let tostring x = match x with FOO -> "FOO" | BAR -> "BAR"' ?
seafood has quit [Read error: 104 (Connection reset by peer)]
seafood has joined #ocaml
Jeff_123 has quit []
r0bby has quit [Client Quit]
r0bby has joined #ocaml
<bluestorm> MelanomaSky: no there isn't
<bluestorm> but you can use syntax extensions to build those functions for you
<bluestorm> eg. sexplib
<bluestorm> (it's quite more powerful than that actually)
seafood has quit []
<MelanomaSky> bluestorm: Hrm, thanks..
preferred has joined #ocaml
seafood has joined #ocaml
coucou747 has quit ["bye ca veut dire tchao en anglais"]
bluestorm has quit [Remote closed the connection]
Philonous1 has joined #ocaml
preferred_ has joined #ocaml
preferred_ has quit [Client Quit]
asmanur has quit [Read error: 110 (Connection timed out)]
Mr_Awesome has quit [Remote closed the connection]
Philonous has quit [Read error: 113 (No route to host)]
preferred has quit [Read error: 110 (Connection timed out)]
Philonous has joined #ocaml
Philonous1 has quit [No route to host]
seafood has quit []
Mr_Awesome has joined #ocaml
tvn1981a has quit [Read error: 110 (Connection timed out)]
jimmygoon has joined #ocaml
<jimmygoon> I've got a project here that uses Ocaml, I've never even heard of it before and I'm getting a make error, the package is horridly out of date though
<jimmygoon> The files /usr/lib/ocaml/3.10.0/lablgtk2/glGtk.cmi
<jimmygoon> and /usr/lib/ocaml/3.10.0/lablgl/glDraw.cmi make inconsistent assumptions
<jimmygoon> is what I'm getting. Can anyone give me a pointer? Thanks a bunch!
Philonous has quit [Client Quit]
Philonous has joined #ocaml
pantsd has quit [Read error: 110 (Connection timed out)]
pantsd has joined #ocaml
jimmygoon has quit ["Leaving"]
<tsuyoshi> jimmygoon: is that the entire message?
kig has quit [Remote closed the connection]
Jeff_123 has joined #ocaml
gdmfsob has quit [Read error: 110 (Connection timed out)]
<Jeff_123> sorry, there's not really a better way
<palomer> hello
<palomer> how do I the difference of two lists
<palomer> {a | \y -> not (List.mem y lst}
<palomer> difference lst1 lst2 = List.filter (fun y -> not (List.mem y lst2)) lst1
<palomer> seems a little wasteful
<Jeff_123> ya that is a bit. 1 sec I'll get back to you
gdmfsob has joined #ocaml
Camarade_Tux has joined #ocaml
<Jeff_123> ok got it
ikatz has quit [Read error: 110 (Connection timed out)]
<Jeff_123> palomer: http://pastebin.com/m68ba7952
ygrek_away has joined #ocaml
<tsuyoshi> probably better if you use sets
<Jeff_123> wouldn't sets potentially be slower?
<tsuyoshi> member ship test is much much faster
<tsuyoshi> membership
arquebus has joined #ocaml
<tsuyoshi> if you have two sorted lists then you can make it faster still though
<Jeff_123> well, of course, but I was assuming not sorted
Asmadeus has joined #ocaml
<tsuyoshi> yeah
<Jeff_123> wait tsuyoshi - did you mean use sets instead of lists, or sets instead of hashtables?
<tsuyoshi> hashtables?
seafood has joined #ocaml
<Jeff_123> Right, hash tables.
<tsuyoshi> must've been in that link I didn't look at yet...
seafood has quit [Read error: 104 (Connection reset by peer)]
<Jeff_123> oh I see, when you said "probably better if you use sets" you were talking to palomer
seafood has joined #ocaml
<tsuyoshi> yeah.. ok for your solution.. I bet a map would work better.. but that's not a huge difference
<Jeff_123> I thought about using map, but it would be a bit slower I think.
<tsuyoshi> I guess the question is really what you need a difference between lists for?
<Jeff_123> I needed it to answer palomer's question :)
<tsuyoshi> if you have enough elements where the obvious filter/mem solution is too slow, then you probably shouldn't be using lists to begin with
<Jeff_123> You're preaching to the choir! :)
Yoric[DT] has joined #ocaml
arquebus has quit [Remote closed the connection]
rwmjones has joined #ocaml
<palomer> heh
<palomer> tsuyoshi is right
<palomer> might as well stick to the filter/mem solution until it becomes a bottleneck
<Jeff_123> aw, my poor memoized difference function :( :(
pantsd has quit [Read error: 110 (Connection timed out)]
pants1 has joined #ocaml
rby has joined #ocaml
OChameau has joined #ocaml
Associat0r has quit []
Jeff_123 has quit []
Yoric[DT] has quit ["Ex-Chat"]
asmanur has joined #ocaml
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
seafood_ has joined #ocaml
Mr_Awesome has quit ["aunt jemima is the devil!"]
seafood has quit [Read error: 110 (Connection timed out)]
ygrek_away has quit [Remote closed the connection]
ygrek_away has joined #ocaml
bebui has joined #ocaml
bebui has left #ocaml []
seafood has joined #ocaml
comglz has joined #ocaml
comglz has quit [Client Quit]
comglz has joined #ocaml
comglz has quit [Client Quit]
redocdam has joined #ocaml
seafood_ has quit [Read error: 110 (Connection timed out)]
ikatz has joined #ocaml
comglz has joined #ocaml
comglz has quit [Client Quit]
comglz has joined #ocaml
comglz has quit [Client Quit]
comglz has joined #ocaml
bluestorm has joined #ocaml
gildor has joined #ocaml
guillem_ has joined #ocaml
asmanur_ has joined #ocaml
asmanur has quit [Read error: 104 (Connection reset by peer)]
Yoric[DT] has joined #ocaml
comglz_ has joined #ocaml
Axioplase has joined #ocaml
Axioplase has quit [Client Quit]
Axioplase has joined #ocaml
seafood has quit []
Jedai has joined #ocaml
comglz has quit [Read error: 110 (Connection timed out)]
marmotine has joined #ocaml
Axioplas1 has joined #ocaml
Axioplas1 has quit [Client Quit]
asmanur_ has quit [Read error: 110 (Connection timed out)]
Linktim has joined #ocaml
coucou747 has joined #ocaml
<rwmjones> camlp4 question ...
<rwmjones> how do I build a tuple from a list of expressions?
<rwmjones> my naive attempt was:
<bluestorm> ah, this one is slightly tricky
<bluestorm> iirc it's something like
<rwmjones> let fields =
<rwmjones> match fields with
<rwmjones> | [] -> <:expr< () >>
<rwmjones> | f :: fs ->
<rwmjones> List.fold_left (fun fs f -> <:expr< $fs$, $f$ >>) f fs in
<rwmjones> but that builds (((a,b),c),d)...
<bluestorm> <:expr< ($head$, $fold tail$) >>
<bluestorm> because the (.. , .. ) construct has to take two expressions
<bluestorm> (it ensures you don't try to build empty or unary tuples)
<rwmjones> bluestorm, do you mean to literally write $fold tail$?
<bluestorm> hm
<bluestorm> nope
<bluestorm> you have to define fold yourself to build a comma-separated expression from the list
<bluestorm> that's the fold_left you've done
* rwmjones no comprende
<bluestorm> well
<bluestorm> try
<bluestorm> | a::b::tl -> <:expr< ($f$, $List.fold_left (fun a b -> <:expr< $a$, $b$ >> b tl$) >>
<bluestorm> you have to do something for the singleton case because a singleton tuple is probably not what you want
<mfp> isn't there some $list:exprs$ or so for this?
<bluestorm> (i'm not even sure the OCaml AST would accept it, you could have an assertion failure instead)
<bluestorm> mfp: that's a good question : to what i understand, there was a limited support for that in pre-3.10 camlp4, wich was removed due to inconsistencies
<bluestorm> i also spotted some similar things in the actual calmp4 source code, but i'm not sure they're supposed to work
<mfp> I see the revised parser uses e1 = SELF; ","; e2 = SELF -> <:expr< $e1$, $e2$ >> so the left-fold is the way to go, as ugly as it is
<bluestorm> mfp: the problem is that comma alone won't build a tuple
<bluestorm> to build a tuple you need the comma plus the parenthesis
<bluestorm> (wich is the only sane way to do, because in ocaml (a, b, c) and (a, (b, c)) are certainly not the same)
<bluestorm> rwmjones: the pure-AST way to do it would be
<bluestorm> Ast.ExTup (_loc, List.fold_left (fun fs f -> <:expr< $fs$, $f$ >>) f fs)
<bluestorm> i think the quotation way is better because it forces you to handle the empty and singleton case yourself
* rwmjones tries the pure AST way
pango_ has quit [Remote closed the connection]
<rwmjones> bluestorm, this is what I've got right now, but it doesn't work:
<rwmjones> let build_tuple_from_exprs _loc exprs =
<rwmjones> match exprs with
<rwmjones> | [] -> assert false
<rwmjones> | x :: xs ->
<rwmjones> Ast.ExTup (_loc, List.fold_left (fun xs x -> <:expr< $xs$, $x$ >>) x xs)
<rwmjones> that builds (((((a,b),c),d),...
<bluestorm> (ouch, using "xs" for the left accumulator is confusing)
<bluestorm> rwmjones: hmm
<bluestorm> i have an ugly idea
<bluestorm> try
<bluestorm> Ast.ExCom (_loc, x, xs) instead of <:expr< ... >> (so that's really pure)
<bluestorm> that's not necessary but i suspect that
<bluestorm> you are using camlp4oof
<rwmjones> camlp4of in fact
<bluestorm> that's probably the same
<bluestorm> and it might be that <:expr< a, b >> is equivalent to <:expr< (a, b) >> as in classical syntax
<bluestorm> whereas it is not in revised, so <:expr< a, b >> would be legal with camlp4orf
<bluestorm> (s/be legal/works/)
gdmfsob has quit [Read error: 104 (Connection reset by peer)]
<rwmjones> I can obviously do <:expr< (a,b,c) >>, but of course I don't know the number of expressions
<bluestorm> btw. in case you need it (i need it everytime i want to use it), the "pure AST" documentation is http://bluestorm.info/camlp4/camlp4-doc/Sig.Camlp4Ast.html
<rwmjones> bluestorm, it works!
<rwmjones> let build_tuple_from_exprs _loc exprs =
<rwmjones> match exprs with
<rwmjones> | [] -> assert false
<rwmjones> | x :: xs ->
<rwmjones> Ast.ExTup (_loc, List.fold_left (fun xs x -> Ast.ExCom (_loc, x, xs)) x xs)
<bluestorm> but
<bluestorm> you should assert false for both empty an sigleton list
<bluestorm> d
<bluestorm> | [] | [_] -> assert false
<rwmjones> oh right, of course
cosmin_ap1 has joined #ocaml
pango_ has joined #ocaml
jeddhaberstro has joined #ocaml
cosmin_ap1 has left #ocaml []
munga_ has joined #ocaml
Associat0r has joined #ocaml
lde has quit [Read error: 110 (Connection timed out)]
ikatz has quit [Read error: 110 (Connection timed out)]
rby has quit ["Quitte"]
lde has joined #ocaml
Linktim_ has joined #ocaml
kig has joined #ocaml
jlouis has joined #ocaml
Linktim has quit [Read error: 110 (Connection timed out)]
comglz_ has quit [Client Quit]
jderque has joined #ocaml
Proteus has quit [SendQ exceeded]
OChameau has quit ["Leaving"]
twobitwork has joined #ocaml
haveo has joined #ocaml
<twobitwork> is there a function to apply a function to values? i.e., I have a list of functions and I want to fold them on a value
besiria has joined #ocaml
<twobitwork> ohh, hi vixey :)
<vixey> hi
<twobitwork> right... but how do I get it to apply the functions in the list to the returned values?
<twobitwork> i.e. in, haskell you would use ($)
<flux> let apply f a = f a ?
<flux> so: there is no standard library function
<bluestorm> well, List.fold_right (fun func x -> func x) yourlist yourval
<twobitwork> ok
<flux> you could use $ too, but that can cause trouble when dealing with campl4
<flux> (I hear)
<bluestorm> and $ has the wrong associativity anyway
<hcarty> bluestorm: Unless you use pa_infix from the pa-do project to change the associativity :-)
wlmttobks has quit ["Leaving"]
wlmttobks has joined #ocaml
ctsprsrcl has joined #ocaml
crdlctelcj has joined #ocaml
profmcdgy has joined #ocaml
unidinph has joined #ocaml
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
jderque has quit ["leaving"]
jeddhaberstro has quit []
Theq629 has joined #ocaml
<twobitwork> flux: is there a $ in ocaml? I don't see it anywhere
<vixey> twobitwork: You probably don't need it but you can define it yourself
<twobitwork> or, do you mean, define it?
<twobitwork> I see
<bluestorm> let ($) f x = f x
<twobitwork> yeah, I see now
<mfp> twobitwork: ($) has got the wrong associativity though. You can use (@$) for instance.
<twobitwork> mfp: I'm not sure I know what you mean
<mfp> a $ b $ c is (a b) c
<mfp> not a (b c)
<twobitwork> well... if I'm defining ($) then I can define its associativity, no?
<mfp> not in OCaml
<twobitwork> ohh... its been a while
<twobitwork> defining it as @$ changes the associativity?
<mfp> the associativity and precendence of any new operators is determined by the first char
<twobitwork> I see
<mfp> for right-associative ops, you have @, ** and ^
<mfp> might be forgetting some
<twobitwork> well... I'll just call it "apply" :) I'm just using it in "fold_left apply 0" anyways
<mfp> fold_left is ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
<mfp> you probably want fold_right ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
<twobitwork> ohh... but I need it to be tail recursive
<mfp> there's a tail-recursive fold_right in extlib
<mfp> otherwise fold_left with List.rev :-/
woogs2 has joined #ocaml
woogs2 has left #ocaml []
redocdam has quit []
rwmjones has quit ["Closed connection"]
redocdam has joined #ocaml
redocdam has left #ocaml []
<bluestorm> hm
<bluestorm> pa_holes is actually quite nice to represent apply
<bluestorm> (\ \1 \2 )
asmanur has joined #ocaml
xxx has joined #ocaml
xxx is now known as Guest8978
munga_ has quit [Read error: 113 (No route to host)]
lde has quit [Remote closed the connection]
ikatz has joined #ocaml
asmanur has quit [Remote closed the connection]
ikatz has quit [Read error: 110 (Connection timed out)]
asmanur has joined #ocaml
Asmadeus has quit ["nighters"]
Hadaka has quit [Read error: 60 (Operation timed out)]
mtrimpe has joined #ocaml
mrtes has joined #ocaml
mrtes has left #ocaml []
mrtes has joined #ocaml
Linktim_ has quit ["Quitte"]
mrtes has left #ocaml []
lde has joined #ocaml
Hadaka has joined #ocaml
ygrek_away has quit [Remote closed the connection]
seafood has joined #ocaml
seafood_ has joined #ocaml
lde has quit [Remote closed the connection]
profmcdgy has quit [K-lined]
wlmttobks has quit [K-lined]
unidinph has quit [K-lined]
haveo has quit [Remote closed the connection]
seafood has quit [Connection timed out]
seafood_ has quit [Connection timed out]
jlouis has quit ["Leaving"]
Philonous has quit ["Leaving."]
mbtrimpe has joined #ocaml
mbtrimpe has quit [Client Quit]
marmotine has quit ["mv marmotine Laurie"]
besiria has quit [Remote closed the connection]
mtrimpe has quit [Read error: 110 (Connection timed out)]
TypedLambda has joined #ocaml
TypedLambda has quit [Remote closed the connection]
Yoric[DT] has quit ["Ex-Chat"]
arquebus has joined #ocaml
arquebus has left #ocaml []
hnr has joined #ocaml
jeddhaberstro has joined #ocaml
asmanur has quit [Read error: 110 (Connection timed out)]
ikatz has joined #ocaml
Jeff_123 has joined #ocaml
<Jeff_123> palomer, what did you end up doing for list difference?
asmanur has joined #ocaml
Jedai has quit [Read error: 110 (Connection timed out)]
Morphous has quit [Read error: 110 (Connection timed out)]
Morphous has joined #ocaml
LDE has joined #ocaml
guillem_ has quit [Remote closed the connection]
jdh30 has joined #ocaml
Axioplase is now known as Axioplase_
woogs2 has joined #ocaml
<woogs2> hi