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)]
<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)