systems changed the topic of #ocaml to: Archive of Caml Weekly News http://pauillac.inria.fr/~aschmitt/cwn/ | ICFP Programming Contest 2003 http://www.dtek.chalmers.se/groups/icfpcontest/
docelic has quit ["sleepo sleep"]
systems has joined #ocaml
systems changed the topic of #ocaml to: Archive of Caml Weekly News http://pauillac.inria.fr/~aschmitt/cwn/ | ICFP Programming Contest 2003 http://www.dtek.chalmers.se/groups/icfpcontest/ | Good free book http://cristal.inria.fr/~remy/cours/appsem/
<bk_> hmm
<bk_> sets are a pain in the ass to use
<systems> what are sets?
<bk_> ocaml does have a Set module, too
<bk_> my code is a mess
<systems> I dont know c++ :/
<bk_> Set is a Sorted Associative Container that stores objects of type Key. Set is a Simple Associative Container, meaning that its value type, as well as its key type, is Key. It is also a Unique Associative Container, meaning that no two elements are the same.
<bk_> you actually only need the description of what a Set os
<bk_> is
<systems> :)
<systems> yea
<systems> they seem to be excatly like hash-tables/dictionaries
<systems> what's a pain about em ?
bk___ has joined #ocaml
<bk___> oops
<systems> welcome
<bk___> sets contain the <key> only once which is why i wanted to use them
<bk___> ie. i don't have to go through the whole structure myself to see if something with the same key is already in
<systems> well same thing for dicts in python
<bk___> yea, i guess so
<systems> but python have sets too
<Smerdyakov> Why are sets a pain to use..?
<bk___> have you used them ?
<bk___> perhaps they're only a pain to use because i haven't used sets in ocaml before and i'm still struggling a bit with the language
<systems> aaaahhh, i checked cheked this books
<systems> sets only have keys
<systems> sets are also unordered
bk_ has quit [Read error: 104 (Connection reset by peer)]
bk___ is now known as bk_
<Smerdyakov> bk___, that is probably why. If you could give a concrete reason why they're a pain to use, then maybe I could help you.
<systems> yea yea, tell us about what you failed to do >:)
<bk_> i have trouble to retrieve the cardinality of a set, however as i said before, that might be due to the lack of my ocaml practice
<bk_> erm i had trouble
<bk_> its working but i think its ugly
<Smerdyakov> bk_, it's not exactly efficient to do, but you can always be keeping track of it yourself as you go along.
<bk_> well i could post my horrible code heh
<bk_> care to see and comment on it ?
<Smerdyakov> OK
<bk_> here goes
<bk_> type entry = {
<bk_> mutable name : string ;
<bk_> mutable count : int ;
<bk_> mutable reply : string
<bk_> }
<bk_> ;;
<bk_>
<bk_> module Myset = struct
<bk_> type t = entry
<bk_> let compare x y =
<bk_> if x.name < y.name then -1
<bk_> else if x.name > y.name then 1
<bk_> else 0
<bk_> end;;
<bk_>
<bk_> module MSet = Set.Make(Myset);;
<bk_> let myentry = { name = "bar"; count = 0; reply = "502 Error !" }
<bk_> let myentry2 = { name = "baz"; count = 1; reply = "503 Error !" }
<bk_> let myentry3 = { name = "boo"; count = 1; reply = "503 Error !" }
<bk_>
<bk_> let mset = ref MSet.empty ;;
<bk_> let adds s = mset := (MSet.add s !mset) ;;
<bk_>
<bk_> let print_set () =
<bk_> print_string "set elements : ";
<bk_> adds myentry;
<bk_> adds myentry2;
<bk_> adds myentry3;
<bk_> print_int (MSet.cardinal !mset);
<bk_> print_newline ()
<bk_> ;;
<bk_> ---<fin>
<systems> i hate the ocaml docs , i never understood how to use em
japheth has joined #ocaml
<japheth> Hello.
<Smerdyakov> You don't understand how to "use" http://caml.inria.fr/ocaml/htmlman/libref/Set.S.html?
<systems> yes
<Smerdyakov> systems, then go die.
<Smerdyakov> bk_, what's the problem? That all looks fine.
<bk_> hm well now it does :>
<japheth> Does anyone here know if there are any functions around for recursive directory copying? (User made ones, or something I've missed. Either are fine. :))
<Smerdyakov> bk_, what did you want me to say about it? :\
<bk_> i thought perhaps i made it unnecessarily complicated
<Smerdyakov> bk_, one small improvement would be to write the compare method in your Set parameter to be: let compare x y = compare x.name y.name
<Smerdyakov> bk_, and it's not possible to say whether it's too complicated without an idea of what your overall goal is.
<bk_> the goal was simply to create a datastructure that holds records w/o the need to iterate 'by hand' over the whole structre to avoid double entries
<bk_> and that's just what it does for me now, so i guess its kinda okay
<Smerdyakov> Then a set sounds like a reasonable match, though perhaps a map would work better,.
<bk_> i'm just annoyed at myself because it took me so long to get it right
<Smerdyakov> You've used some gratuitous imperative features. Any reason why?
japheth has quit []
<bk_> because the map will later be constructed from a text-file and written to another file
<bk_> erm the set
<Smerdyakov> So?
<bk_> so ?
<Smerdyakov> Why does the fact that "the set will later be constructed from a text-file and written to another file" mean that you need to use mutable fields and references?
<bk_> because map elements will be altered in some way or another at some point
<Smerdyakov> So? I take it you haven't used functional languages much.
<bk_> you're right, i haven't
<Smerdyakov> So clearly the mutable fields need not be mutable in your example.
<bk_> say, i have constructed my set and want to alter the 'count' of an entry, why shouldn't it be mutable ?
<Smerdyakov> As for the reference, you could do: let mset = List.fold_right MSet.add MSet.empty [myentry; myentry2; myentry3]
<Smerdyakov> bk_, why do you need toalter the count?
<bk_> because i want to alter it ? its not supposed to be static after all
<Smerdyakov> You can create a new set that has the old element removed and the a new element with an altered count added in its place.
<bk_> that is true
<Smerdyakov> OCaml Set's are functional, so there is no efficiency difference, really. You'd just store the pointer to the set structure in a function parameter instead of in a reference.
<bk_> hm, yes
systems has left #ocaml []
eno has joined #ocaml
eno has quit [Nick collision from services.]
eno_ has joined #ocaml
eno_ has quit [Client Quit]
eno has joined #ocaml
bk_ has quit ["leaving"]
eno has quit ["[BX] Twat?! I cunt hear you!"]
bk_ has joined #ocaml
srv has joined #ocaml
d-bug has joined #ocaml
<d-bug> morning
brwill is now known as brwill|zzz
<bk_> i take everything back
<bk_> sets are acutally not a particular pain in the ass to use
<bk_> they're pretty handy
systems has joined #ocaml
<systems> sup
* bk_ tired
<systems> :/
<systems> why
<bk_> been up all nite
<systems> aha
<systems> well, drink more coffee, take a shower
<systems> continue
<bk_> :>
<systems> up time is the most important time
<systems> sleep, hah, sleep is like computer reboot
<bk_> heh
<systems> but well, you need i think 6 hours a day to remain healthy
<bk_> yea, i know
<systems> plus, it's better to sleep like 2 hours wake up continue, then to continue with half ... am not sure i know the english word
<systems> mmmm ... 1/2 power you know, perception is less, attention is less etc...
<d-bug> hi
<bk_> heh well i dunno, i'm making slow but steady progress now w/ learing ocaml and tonight i learned abit about modules and sets, so i'm kinda satisfied for today
<d-bug> try ginseng :)
<systems> yea thats fair
<systems> i prefer slow and steady
<systems> well, the way i prefer to learn is i read as much as i can about the new thing i am tryin to learn
<systems> without really lookin that deep into the details
<systems> then another round to get more on the details
<systems> then another , then another , etc ....
<bk_> same here, sort of
<systems> i prefer the big picture style , divided in like layers
<systems> :)
<systems> bye
systems has quit ["Client Exiting"]
docelic has joined #ocaml
docelic has quit ["l8"]
bk_ has quit ["leaving"]
bk_ has joined #ocaml
karryall has quit ["bye"]
systems has joined #ocaml
systems has left #ocaml []
CybeRDukE has joined #ocaml
foxster has quit [Client Quit]
docelic has joined #ocaml
polin8 has quit ["Lost terminal"]
foxster has joined #ocaml
polin8 has joined #ocaml
docelic has quit ["Client Exiting"]
srv has quit [Remote closed the connection]
brwill|zzz is now known as brwill|work
lam has quit ["Lost terminal"]
lam has joined #ocaml
<d-bug> it's a bit too quiet here despite the many folks in here :-/
srv has joined #ocaml
<d-bug> hi srv
<srv> d-bug: hi :)
bk_ has quit ["I'll be back"]
bk_ has joined #ocaml
<d-bug> what's up srv
<srv> sorry I'm busy...
CybeRDukE has quit ["Drag me, drop me, treat me like an object!"]
srv has quit [Remote closed the connection]
docelic has joined #ocaml
mattam_ has joined #ocaml
Xcalibor has joined #ocaml
<Xcalibor> hiyas
Xcalibor has quit [Client Quit]
Xcalibor has joined #ocaml
<Xcalibor> re's
srv has joined #ocaml
<d-bug> hi bk_
<d-bug> Xcalibor i mean :)
mattam has quit [Read error: 110 (Connection timed out)]
<Xcalibor> d-bug: hello :)
srv has quit ["Bye"]
srv has joined #ocaml
<d-bug> i wonder if there's an easy way to do cooperative multithreading in ocaml
<Xcalibor> cooperative multithreading?
<Xcalibor> mmm...
<Xcalibor> maybe using Weak?
<Xcalibor> i cannot think of an easy way, sorry.. but I'm fairly newbie in ocaml...
polin8 has quit ["Lost terminal"]
<teratorn> d-bug: why do you want to do that?
polin8 has joined #ocaml
<d-bug> teratorn: for implementing a DSL to describe game ai
<teratorn> dsl?
<d-bug> user-land threads is almost what I want, but the pre-emptiveness introduces complexity for the DSL, I want to avoid a lot of code to protect data
<d-bug> DSL = domain specific langauge
<teratorn> that is a good thing to want to avoid :)
<teratorn> hmm.
<d-bug> a langauge specifically designed to be powerful in describing a certain problem domain
<d-bug> Make and Makefiles is a good example of a DSL
<teratorn> yeah. it seems game ai would be primarily a constraints based problem
<teratorn> granted i don't know much about constraints programming, but perhaps ocaml isn't the best language for this. you might check out mozart-oz, as it has special support for constraints programming
polin8 has quit ["Lost terminal"]
<teratorn> also, it has proper concurrency.
polin8 has joined #ocaml
<d-bug> no, I'd like to use common lisp or ocaml for this
<teratorn> eh well, it's just a thought :)
<Xcalibor> in lisp the usual way is by defining higher order functions and macros
<d-bug> ocaml is so very fast in many cases, and lisp is so cool :)
<Xcalibor> that way yo uspecify your DSL on top of Lisp
<d-bug> Xcalibor: right, i started to write a program transformator to transform a DSL(not yet invented) to a CPS style, to implement this cooperative threading, but then I thought I'd look a ocaml more
<d-bug> defmacro is a bit complex for a cl newbie like me :)
<d-bug> it is soo cool to have functions like compile and disassemble in cl
<Xcalibor> yes, it is
d-bug has quit ["night folks"]
asqui has joined #ocaml
docelic has quit ["Client Exiting"]
mattam_ is now known as mattam
srv has quit [Remote closed the connection]
Xcalibor has quit ["Terminando cliente"]