dark_light changed the topic of #ocaml to: OCaml 3.09.2 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
khaladan has quit [Connection timed out]
khaladan_ is now known as khaladan
mikeX has quit ["leaving"]
rillig has quit ["exit(EXIT_SUCCESS)"]
shawn has joined #ocaml
jcreigh has joined #ocaml
shawn has quit ["Leaving"]
chessguy has joined #ocaml
<jeremy_c> The above is a simple claim report program that reports all claim numbers and their dollar amounts in the given file. See how I use DynArray.iter? I want to display a summary at the bottom that contains a claim count, and also a summed claim_charge. I can think of a few ways to do it, but nothing OCaml'ish, nor efficient. Any thoughts?
<jeremy_c> My first thought is to use ref's
shawn has joined #ocaml
chessguy2 has joined #ocaml
b00t has joined #ocaml
chessguy has quit [Connection timed out]
chessguy2 is now known as chessguy
pango has quit [Remote closed the connection]
pango has joined #ocaml
ziggurat has joined #ocaml
<youknow365> is %c a character or %d ?
<youknow365> i knoww %s is strings
<Smerdyakov> Manual manual manual!
<youknow365> Smerdyakov: i know what the yare but i just didnt know about for printing
<Smerdyakov> I don't understand.
<youknow365> i know what a float int char string all that is but i didnt know what is used for printing
<youknow365> %s for strings obviously
<youknow365> %d is for numbers / int right ?
<youknow365> what about float and char
_fab has joined #ocaml
<Smerdyakov> Read the manual and find out.
piggybox has quit []
fab_ has quit [Read error: 110 (Connection timed out)]
<youknow365> << is lookign through manual
<Smerdyakov> Should be completely obvious where to find it.
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- The future of IRC"]
shawn has quit ["This computer has gone to sleep"]
chessguy has joined #ocaml
teratorn has joined #ocaml
<youknow365> for my jabber client i am dividing up my xml - all the im functions - and then tieing it all together .....is that a good idea ? or a bad one ......will put them in different places make things slower ? or should that not be an issue
<teratorn> where does the sleep() function live in ocaml?
jewel has joined #ocaml
<teratorn> this must be an easy question (?)
jewel has quit [Read error: 104 (Connection reset by peer)]
<teratorn> anyone have any information about the performace of compiled programs using the MingW version of Ocaml vs. the MSVC version?
<teratorn> I'm wondering if the produced programs will vary at all in memory or CPU usage?
<youknow365> teratorn: no idea
<youknow365> pango: what kind of type is an ip address a float ?
jewel has joined #ocaml
<youknow365> is the only way i can store an ip address as a variable is by making it a string ?
teratorn has quit [Read error: 104 (Connection reset by peer)]
teratorn has joined #ocaml
shawn has joined #ocaml
teratorn has quit [Read error: 104 (Connection reset by peer)]
Carillon_ has quit [Read error: 104 (Connection reset by peer)]
Carillon_ has joined #ocaml
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
smimou has joined #ocaml
<flux__> hmm.. how would I debug an ocaml program, that sometimes just exits?
<flux__> it's threaded, does networking and uses postgresql..
<flux__> but I can't understand why it would just exit
_velco has joined #ocaml
<TSC> Debugging output statements (:
<flux__> I guess I could just put _tons_ of debug messages everywhere
<flux__> (but I'm not sure how helpful that is)
<flux__> I think strace won't work quite well with threaded programs, and it would slow it down plus create too much debug info
b00t has quit [Remote closed the connection]
teratorn has joined #ocaml
teratorn has quit [Read error: 54 (Connection reset by peer)]
<youknow365> flux__: what type should i put an ip address in ? string float int ? which one is best ?
<flux__> Doesn't unix-module provide a structure for ip-addresses
<flux__> it it can be a name, string
<youknow365> name ?
<youknow365> this is not the ip for connecting jabber requires you send them the ip of the server you are connecting to
<flux__> "like.a.name.com"
<youknow365> so its not used ofr connecting .........just to send in the XML
<flux__> I meant to say 'if it can..'
teratorn has joined #ocaml
<youknow365> flux__: what ?
<youknow365> <stream:stream xmlns:stream=\"http://etherx.jabber.org/streams\" xmlns=\"jabber:client\" to=\"71.65.22.111\">";;
<youknow365> where it says ip
<youknow365> i want that to be a variable
<youknow365> which i will assing ot be ip
<flux__> just use strings, it may be more convenient if it's just being used as opaque data (data comes in, you pass it forward)
<flux__> but don't you want to use Unix-module to determine your ip-address?
<youknow365> i dont need to determine my ip
<flux__> ok
<youknow365> this is my jabber servers ip
<youknow365> so i shoulf just store it as a string ?
<youknow365> flux__: ^^ :)
teratorn has quit [Read error: 54 (Connection reset by peer)]
pango has quit ["brb"]
m3ga has joined #ocaml
Wild_Cat has joined #ocaml
b00t has joined #ocaml
Carillon has joined #ocaml
m3ga has quit ["disappearing into the sunset"]
[1]Revision17 has joined #ocaml
teratorn has joined #ocaml
Revision17 has quit [Read error: 110 (Connection timed out)]
[1]Revision17 is now known as Revision17
Carillon_ has quit [Read error: 110 (Connection timed out)]
Carillon is now known as Carillon_
b00t has quit [Remote closed the connection]
smimou has quit ["bli"]
ulfdoz has joined #ocaml
ulfdoz has quit ["deprecated"]
ulfdoz has joined #ocaml
DRMacIve1 is now known as DRMacIver
<youknow365> let authenticate_connect_xml = Format.sprintf "<iq type=\"set\" id=\"auth_2\" to=\"%s jabber_ip\" >" ;;
<youknow365> you guys see anything wrong with this ?
<flux__> %s jabber_ip?
<youknow365> yes?
<flux__> it should be like Format.sprintf "<iq type=\"set\" id=\"auth_2\" to=\"%s\" >" jabber_ip
<flux__> (disclaimer: I haven't used the Format-module)
<youknow365> ooooooooo
<youknow365> flux__: thanks but if i have multiple %s inside of it or int how do i do that ?
<youknow365> do they go in order?
<flux__> yes
<youknow365> btw int are %d right ?
<youknow365> i am 99.9 percent sure
<flux__> yes
<youknow365> in basic its reversed
<youknow365> flux__: http://phpfi.com/153000 do you see anything wrong there ?
Revision17 has quit [Read error: 110 (Connection timed out)]
<flux__> atleast ocaml doesn't
<flux__> assuming jabber_ip is a string and jabber_un an integer
<youknow365> let jabber_ip = "71.65.50.313"
<youknow365> ;;
<youknow365> let jabber_un = test101
<youknow365> ;;
<flux__> what is test101?
<youknow365> a test jabber user account
<flux__> so it's an integer?
<youknow365> huh?
<youknow365> are you asking if its a number?
<flux__> is its type also integer? that is, does ocaml say ' : int' when you type test101 to caml
<youknow365> no i am getitng unbound error for test101
<flux__> you mean "test101" then?
<youknow365> only reason i made the ip a string was becasue all the .'s
<flux__> obviously written like that test101 must be a variable name
<youknow365> flux__: that would make it a string though right ?
<flux__> yes
<youknow365> cant i leave it as a int or w/e
<flux__> sure. I don't understand what the problem here is..
<youknow365> let jabber_un = test101
<youknow365> ;;
<youknow365> do you see a problem with that ?
<flux__> no, if you have defined test101 earlier
<youknow365> i have not
<flux__> ..
<youknow365> i thought thats what this was doing
<flux__> you're defining jabber_un
<flux__> not test101
<youknow365> i want jabber_un to equal the letters test101
<flux__> well in that case it must be a string?
<flux__> and "test101" is the way to represent that
<youknow365> it must?
<flux__> well string is a sequence of letters
<flux__> and that's what you want, right?
<youknow365> yes
<youknow365> but is using all these strings and pulling in other strignsthrough it bad ?
<flux__> not really
<youknow365> is there any other options ?
<flux__> you could have a list of characters
<flux__> but I don't understand why string wouldn't be perfectly suitable here
<youknow365> ok if you say a string is ok i belive you :P
<youknow365> flux__: i have read over everything but what exactly is a char .......i mean a character buut i dont get it
<youknow365> and i thought int was numbers
<youknow365> and float was like 1.5
<flux__> char is like 'a'
<youknow365> just one character ?
<flux__> yes
<youknow365> wtf
<youknow365> why would anyone ever use that ?
<flux__> well, let's say you have a function that returns input from the user
<flux__> you will know it's extactly one character at a time
<flux__> then you want to use 'char'
<flux__> the code always knows there's exactly one character and no need to worry about having no characters or many characters
<youknow365> i seeeee
<youknow365> i seeeee
<youknow365> and int is number right ?
<flux__> yes
<youknow365> ok ok ..........doesnt ocaml like already define the types for you ?
<flux__> yes
<flux__> "hello".[4] = 'o' demonstrates usage of strings, integers, booleans and characters
<youknow365> whreres the bool ?
<flux__> the return value is either true or false (true in this case)
<youknow365> oooooo
<youknow365> sorry was stupid :(
<youknow365> flux__: Format.sprintf "<iq from='%s@%s/balcony' type='get' id='roster_1'>
<youknow365> you see a problem with that at all ?
teratorn has quit [Read error: 104 (Connection reset by peer)]
<flux__> no, if you terminate the string with " and give it two parameters
<youknow365> i did
<youknow365> buuuuuut
<youknow365> "fprintf: bad format ``<iq from='%s@%s/balcony' type='get' id='roster_1'>\n <query xmlns='jabber:iq:roster'/>\n </iq>'', giving up at character number 13 (%).".
<youknow365> i think its because %s@
<flux__> oh, right
<youknow365> am i doing something wrong here ?
<flux__> Format-module doesn't work like Printf-module
<flux__> refer to Format documentation
ziggurat has quit ["Leaving"]
<youknow365> its that @ thats throwing it off
<youknow365> flux__: theres nothing about this on there
<youknow365> val sprintf : ('a, unit, string) format -> 'a
<youknow365> Same as printf above, but instead of printing on a formatter, returns a string containing the result of formatting the arguments. Note that the pretty-printer queue is flushed at the end of each call to sprintf.
<youknow365> In case of multiple and related calls to sprintf to output material on a single string, you should consider using fprintf with a formatter writing to a buffer: flushing the buffer at the end of pretty-printing returns the desired string. You can also use the predefined formatter str_formatter and call flush_str_formatter () to get the result.
<youknow365> na nan
<youknow365> i think i got it
<youknow365> ah ha worked ........ you have ot use two @@'s
Carillon_ has quit [Read error: 104 (Connection reset by peer)]
DRMacIve1 has joined #ocaml
<youknow365> flux__: you still up ........im not sure if the way i am doing this is good in terms of design
<flux__> maybe not, but you can later rewrite it
<youknow365> flux__: http://phpfi.com/153017 << does that look ok to you dont pay attention to those variable declaration at top i will put those in a global file that the whole program can use
<youknow365> then basically i have functions that send that xml to the jabber server and handle response etc
<flux__> it's ok at that stage
Carillon_ has joined #ocaml
<youknow365> well i didnt want to include the XML in with the functions that would be long and terrible etc
<youknow365> i just have all the xml in one file declared as its own variable so its easy to call when time to send XML
<youknow365> my other option is putting the xml right in the sock send
<youknow365> which would look horrible
_fab has quit []
<flux__> it needs to be in a string anyway for Unix.write
<youknow365> my last option would be to use a XML parser which i am going to have to use to parse the XML ......but is make the xml ........but i think you are only suppose to do that *IF* you do not know what to expect ......this XML will be the same everytime that is sending to the server
<youknow365> you know what i mean ?
DRMacIve1 is now known as DRMacIver`
<flux__> you want to use an xml parser if that was the question
<youknow365> flux__: no no ;)
<youknow365> sorry its getting late :P
<youknow365> 7 am late
<luca83> youknow365: what are you programming? :)
<youknow365> buuuut ........another way is by making the XML by means of an XML parser / generator .......but your only suppose ot make the XML if you do not know what to expect
<youknow365> i anwsered my own question
<youknow365> luca83: a Jabber Client
<youknow365> luca83: and quite a bit is done
<luca83> youknow365: :) good
<youknow365> if i finish gui tomorrow and spend a few days hooking it all together i should be done soon
<luca83> are there some libraries for xmpp that you might use?
DRMacIver has quit [Read error: 110 (Connection timed out)]
<youknow365> there *were*
<luca83> ahh...
DRMacIver` is now known as DRMacIver
<youknow365> jabbr
<luca83> yes, obviously :)
<youknow365> but last update 02
<youknow365> and 2ndly i basically have the jabber library written ;)
<luca83> ;)
<youknow365> just got to do xml parsing for roster list and all is good
<youknow365> also does lablgtk wwrap the eggtrayicon anyone know ?
<youknow365> if *not* thats just another thing to add to the list :(
Carillon_ has quit [Read error: 60 (Operation timed out)]
<luca83> I don't know, I think I'll use lablgtk in the future
<youknow365> 1 or 2 ?
<youknow365> also i wonder if it wraps the whole GTK including eggtrayicon in that or not hmmmmmm
<youknow365> i dont htink it wraps libeggtrayicon
<youknow365> but then again i think its included by default now
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- State of the art IRC"]
<youknow365> ahlin_> youknow365: yes, in gtk+ 2.10 it's included under the name GtkStatusIcon
<youknow365> good news since lablgtk2 recomends 2.4.x or higher then i would think they have implmented this as well
Carillon_ has joined #ocaml
jewel has quit [Read error: 104 (Connection reset by peer)]
jewel has joined #ocaml
jewel has quit [Read error: 104 (Connection reset by peer)]
jewel has joined #ocaml
Demitar has quit ["Ex-Chat"]
Demitar has joined #ocaml
m3ga has joined #ocaml
jewel has quit [Connection timed out]
m3ga has quit ["disappearing into the sunset"]
gim_ has joined #ocaml
velco has joined #ocaml
pango has joined #ocaml
<jeremy_c> Anyone have comment on how I handle total_charge/claim_count in the above 16 line script?
<jeremy_c> I'm just not sure about it's "properness" because it has side effects. But thus far, I have not been able to program in ocaml w/o side effects.
<pango> you could use fold_left...
<pango> but printfs are also basically side-effects, so it will still not be purely functional ;)
<pango> # List.fold_left (fun acc e -> acc +. e) 0. [1.;2.;3.;4.] ;;
<pango> - : float = 10.
<pango> # List.fold_left (fun (count, sum) e -> (count+1, sum +. e)) (0, 0.) [1.;2.;3.;4.] ;;
<pango> - : int * float = (4, 10.)
<pango> btw, storing your database data as strings does not allow you to benefit from strong static typing... it's just dynamic typing in disguise...
edwardk has joined #ocaml
<jeremy_c> pango: I was thinking I am already looping through the transactions, if I do a fold left, then I will actually have to loop through the same data 2 times.. 1 to print the report, 1 to sum the totals. I guess for claim count, I could do a .length which would work fine. I just didn't want to introduce looping through the array twice.
<pango> # List.fold_left (fun (count, sum, detail) e -> (count+1, sum +. e, detail ^ Printf.sprintf "$%12.2f\n" e)) (0, 0., "") [1.;2.;3.;4.] ;;
<pango> - : int * float * string =
<pango> (4, 10., "$ 1.00\n$ 2.00\n$ 3.00\n$ 4.00\n")
<pango> not that it's the best way to do it, but it's not impossible either
smimou has joined #ocaml
slipstream has joined #ocaml
<pango> let doneio () = () ;;
<pango> let seqio io1 io2 () = let () = io1 () in io2 () ;;
<pango> let count, sum, detail =
<pango> List.fold_left (fun (count, sum, detail) e ->
<pango> (count+1, sum +. e, seqio detail (fun () -> Printf.printf "$%12.2f\n" e))
<pango> ) (0, 0., doneio) [1.;2.;3.;4.] ;;
slipstream-- has quit [Read error: 110 (Connection timed out)]
f78 has joined #ocaml
waern has joined #ocaml
waern has quit [Connection timed out]
velco has quit ["Ex-Chat"]
f78 has quit ["Leaving"]
khaladan has quit [Connection timed out]
f78 has joined #ocaml
gim__ has joined #ocaml
Wild_Cat has quit ["Leaving"]
Revision17 has joined #ocaml
gim_ has quit [Read error: 110 (Connection timed out)]
<jeremy_c> pango: the Edi module is simply to read/write EDI files. It does not pay attention to what the data types are. I should extend the module to support different types of smart EDI file translators. An EDI file itself does not include any type information. You must know what segment you are in, and then which element and compare that to a data map to determine it's type.
_velco is now known as velco
<pango> it doesn't need to be your fault, my claim stands ;)
<jeremy_c> pango: I don't understand what your saying.
<jeremy_c> pango: I was speaking in regards to strong/dynamic typing
shawn has quit ["This computer has gone to sleep"]
postalchris has joined #ocaml
pango has quit ["brb"]
pango has joined #ocaml
shawn has joined #ocaml
<pango> jeremy_c: Well, if data source is basically untyped, there's more than one way to "model" it in a typed system, I was just mentionning that using float_of_string just before use was the most "dynamically checked" approach possible (nice to see you already thought of it)
dbueno has joined #ocaml
<jeremy_c> pango: now, the data/type map... I don't have a clue how to model that yet in ocaml, or any other language, actually. it's so goofy. if seg abc, element 10 has a D8, then seg def, element 5 is a 8 character date, CCYYMMDD, but if abc#10 has D10 then it is in MM-DD-CCYY format, or it could also be blank ... If def#02 = IL then this REF segment is the insured and element 5 of it is last name, element 4 is first, etc...
<pango> if such data is know in advance, the program could be tailored to handle them (maybe using functorization, code generation,...). Otherwise, data could still be "modeled" more tightly than thru strings, most probably by using variants
<dbueno> Anyone: which is the most popular ocaml parser for arbitrary context-free grammars? I'm aware of Elkhound... is it popular?
dbueno has quit ["This computer has gone to sleep"]
dbueno has joined #ocaml
<dbueno> (My laptop died... so if anyone responded, I didn't see it.)
<pango> jeremy_c: which makes me think of http://martin.jambon.free.fr/ocaml.html#col
<pango> dbueno: nope, no one replied in the minute you were away :)
<dbueno> pango, heh, thanks. Hmm.... I don't care much about my parser's runtime, and my ocamlyacc grammar has nasty reduce/reduce exceptions.
<dbueno> I wanted to see if I could get away with not fixing them. =]
<jeremy_c> pango: I'll look at it. I'd have to create prob 200 diff row types.
<jeremy_c> pango: the problem I see with it, jsut at a casual glance, is that an EDI file contains about 200 segments. Each segment (row) is a different format. The single EDI file will contain up to 80 or so of these segments in one file. One EDI file is not a file with 100 rows of the exact same record structure. Each record is totally diff.
<jeremy_c> PAT*10~SV2~NM1*IL*DOE*JOHN*111334444~ would be an example. At each ~ is a diff segment/row. * seps cols. the first element of the segment tells what type of data is going to follow.
<jeremy_c> Most EDI files are also on 1 line. It's crazy, I'll get a 500k EDI file with only 1 line.
<pango> I don't think that col extensions enforces a limit on the number of record types you can use... But I haven't used it to check ;)
<pango> it's sure it would have to be modified for your use, being written to read csv files; But it seems to be an interesting solution to similar problems
dylan has joined #ocaml
dylan has left #ocaml []
<buggs> recomendations for priority queues with less then say 100 elements
<buggs> ?
<pango> I think Sets' min_elt is O(log n)...
pango has quit [Remote closed the connection]
pango has joined #ocaml
Daimun has quit ["Leaving"]
Smerdyakov has quit ["Leaving"]
dbueno has quit ["Leaving"]
chessguy has joined #ocaml
<youknow365> when should references be used ?
shawn has quit [Read error: 110 (Connection timed out)]
<buggs> youknow365, only when you need them, which is usually with non-functional programming style
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- IRC with a difference"]
yacstud has joined #ocaml
postalchris has quit ["Download Gaim: http://gaim.sourceforge.net/"]
velco has quit ["I'm outta here ..."]
f78 has quit ["Leaving"]
<youknow365> isnt a reference like a pointer as in C ?
<smimou> sort of yes
<smimou> excepting you cannot do pointer arithmetic in ocaml
danly is now known as msn
edwardk_ has joined #ocaml
msn is now known as danly
<pango> youknow365: it's like variables
<youknow365> pango: i mean when would i use a refernce over a variable ?
<youknow365> hmmmmmm
<yacstud> youknow365, when you want to change (mutate) the content of the variable
<youknow365> yea but i mean is a refernce something that can be chnged often or is that more for a variable
<youknow365> so use a reference if i want it changed through the program ?
edwardk has quit [Connection timed out]
edwardk has joined #ocaml
yacstud has quit [Remote closed the connection]
jcreigh has joined #ocaml
edwardk_ has quit [Connection timed out]
Carillon has joined #ocaml
edwardk has left #ocaml []
Carillon_ has quit [Read error: 60 (Operation timed out)]
Carillon is now known as Carillon_
smimou has quit ["bli"]
magnus- has joined #ocaml
gim__ has quit []