<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.
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
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
<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 (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>
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.)
<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