<pango>
because the characters are probably already read (and discarded), so it's not the right approach
<dark_light>
Hmmm.. maybe what i want is create another function, like buffer_right_add_channel, that adds up to n characters (but may add less than n)
<dark_light>
and, well, knowing the size in advance with in_channel_length will really helps
<dark_light>
Hmmm.. i was thinking in Unix.read, there are any real advantage in handling directly with file descrs?
<pango>
more control (over opening modes, etc)
<malc_>
dark_light: how big are those files you want to read btw?
<dark_light>
malc_, i hope above 1k, but may be larger
<dark_light>
ops
<dark_light>
below
<malc_>
i see, strings will do then
<dark_light>
pango, only? so i think your approach is fine, tks!
<dark_light>
malc_, why? for large files strings isn't a good idea?
<pango>
strings are limited to 16M chars
<malc_>
erm
<malc_>
on 32bit systems, the limit is 16Mb indeed
<pango>
on 32 bits archs at least
<dark_light>
there are a size counter for strings? hmm
<dark_light>
well, I never liked c strings..
<pango>
there's a size counter on memory blocks... So all memory objects have a maximum size
<dark_light>
pango, why you read more than the buffer's initial size each input()?i thought it's better to have a initial size larger than each block read
<pango>
optimally, I think you want buffer_size to 16384; OCaml runtime splits I/Os in 16kB blocks anyway
<pango>
the optimal size of result depends on the expected size of files, that's independant
<dark_light>
hmmmm
<malc_>
why not just use really_input?
<dark_light>
if i have 10 bytes and do really_input with, let's say, 20 bytes, the function generates a error (and maybe that 10 bytes is already consumed, like Buffer.add_channel)
<dark_light>
when I open a file with open_in, i must close with close_in, or the channel will be garbage-collected and the file automatically close?
<dark_light>
(i don't imagine how the gc will know that before garbage-collecting the channel, it must close the file..)
<malc_>
dark_light: end_of_file will be raised. but uh, you can always use in_channel_length to read precise amount of data
<malc_>
dark_light: it wont be automatically closed
Submarine has quit [Read error: 110 (Connection timed out)]
<dark_light>
malc_, is that what i thinked, but the pango version appear to be more general, working with other things than files..
<pango>
dark_light: OCaml supports finalization, and I think the descriptor will be reclaimed
<pango>
(however you don't know when)
<malc_>
it wont be reclaimed, the file descriptor WONT be closed
<dark_light>
hmm..
<malc_>
dark_light: okay, though i'd prefer to just code something along the lines of Mottls fold_channel
<dark_light>
i really don't got what you said malc_ :P
<pango>
malc_: I'd consider this a bug ;)
<malc_>
# let _ = let ic = open_in ".emacs" in ();;
<whatsup103>
dark_light: your gonna have a big list by time I'm done :D
_velco has joined #ocaml
<dark_light>
er :P
<whatsup103>
:P
<whatsup103>
lol
<whatsup103>
dark_light: i understand how to read ocaml documentation now :D
<dark_light>
:)
<whatsup103>
that whole examples thing the csv gave me .......like they used 8 lines to load a csv file ........took me 1 and i get same result
<whatsup103>
i dont know why people do that
<dark_light>
whatsup103, generally for clarity
<dark_light>
all ocaml programs may be written in one line.. ^^
<whatsup103>
no no
<whatsup103>
i mean
<whatsup103>
it was 8 lines
<whatsup103>
of kinda complicated code
<whatsup103>
mine was
<whatsup103>
load fdfdfdfcsv ;;
<dark_light>
well, sometimes a more complicated code avoid some bugs or is just more fun
<dark_light>
or that person was a really complex person :D
<whatsup103>
lol
<whatsup103>
i cant see how loading a csv file would casue to many problems
<whatsup103>
:D
<whatsup103>
i think they were just trying to look smart
<dark_light>
yeah
<dark_light>
let f x = x+1 in f 2
<whatsup103>
lol
ikaros has quit [Read error: 113 (No route to host)]
Smirnov has joined #ocaml
<Smirnov>
are there hashes in ocaml
<Smerdyakov>
Smirnov, I hope you're not using that word the way that Perl does... AND I hope you realize that OCaml is not so impoverished a language that there could be a feature of that kind not implementable in a library.
* whatsup103
has never used a hash
<whatsup103>
well a md5 hash :D
<Smirnov>
hash table
<Smirnov>
associative array
<Smirnov>
etc?
<Smirnov>
there's no syntactic sugar for them?
<Smerdyakov>
Smirnov, there is nothing built into the language.
<Smerdyakov>
Smirnov, following standard library terminology, we call them maps.
pango has quit [Remote closed the connection]
<Smirnov>
bah with stdlib
<Smirnov>
thats ok, i'll stick with ordered lists of key value pairs then
<whatsup103>
i have seen many small littlel ibs that provide hash tables
<Smirnov>
but its the sugar that makes them so cool
<Smirnov>
otherwise not so sweet
<Smerdyakov>
Smirnov, why don't you want to use Map from the standard library?
<Smerdyakov>
dark_light, perhaps I should have pointed to that, but I like to encourage people migrating from Imperative-land to abandon mutable data structures. :)
<Smirnov>
i'm taking a final today and we might have to implement a memory data structure with some functions ... obviously writing down something using syntactic sugar is better when you are using pencil and paper
<Smerdyakov>
Smirnov, I don't agree. It may be better in highly artificial situations like written exams, but readability would be more important in real-life situations.
<Smirnov>
its for a final
<Smirnov>
how can you not agree?
<Smerdyakov>
Thank you for that extraneous information. :P
<Smirnov>
you just agreed its better for a written exam
<whatsup103>
lol
<Smirnov>
thus by logical proposition you agree and everything else you mentioned is redundant
<Smerdyakov>
Yes, but I didn't agree for _writing_things_down_in_general_.
<Smirnov>
its like saying TRUE or bla bla bla, thats TRUE
<dark_light>
Smerdyakov, but isn't that a bad thing every time i change a data structure, i return a new value? (or the actual values of cells isn't copied? i really worry about that)
<whatsup103>
Smerdyakov: you cant tell people things are not there just becasue ........you dont like the data structure ;)
<Smerdyakov>
dark_light, no, it's not important in practice.
<Smerdyakov>
dark_light, (most of the time)
<Smirnov>
i'm not so worried about typing typing out the full function name on a computer, more so on a time constraint
<Smirnov>
while i'm here can anyone tell me what callcc does, and why ocaml doesnt have it?
<Smerdyakov>
Smirnov, it's unlikely that anyone can explain it on IRC in a reasonable amount of time.
<Smirnov>
i looked at wiki and not so clear, i have not used scheme before
<whatsup103>
Smirnov: maybe you should have studied a few days before the exam :D not a few hours
<Smirnov>
but i wrote an interpreter in ocaml using cps for parsing the syntax tree
<Smirnov>
whatsup103: are you in her class too???
<whatsup103>
yep
<Smirnov>
whats callcc supposed to do
<Smirnov>
i dont get why she threw things in there that we never covered on hw/mps
<dark_light>
hm, if sml has it, it may not be so difficult to port to ocaml, Smirnov
ikaros has joined #ocaml
<whatsup103>
lol
<Smirnov>
dont want to port it, just want to know what it does how it works :)
<Smerdyakov>
dark_light, impossible to implement in ML in general
<whatsup103>
im just kidding im not in her class lol
<Smirnov>
oh you suck
<whatsup103>
what you live
<whatsup103>
where
<Smirnov>
urbana
<whatsup103>
what country
<dark_light>
well, Standard ML of New Jersey: SMLofNJ.Cont.callcc, at the article you pointed, Smerdyakov
<Smerdyakov>
dark_light, yes. They implement it using special compiler support.
<dark_light>
!!
* dark_light
don't like the word "impossible"
<Smerdyakov>
I imagine it's not too hard to prove formally that callcc is unimplementable in SML. OCaml lacking a formal semantics, it's unclear what to do there. :P
<Smirnov>
wtf
<Smirnov>
callcc ( fun k -> k 42) returns 42 ?
<Smirnov>
but whats the point if it evaluates eagerly
<dark_light>
Continuations are the functional expression of the GOTO statement, and the same caveats apply > ahaha ahahah ahahahha
<Smirnov>
useful
<whatsup103>
anyone here with experince with bidning generators please raise your hand ******
<Smirnov>
say if you have callcc (fun k -> something) where does it get k anyways?
<Smirnov>
callcc doesnt seem very useful when you already have real exceptions implementd
<Smerdyakov>
It generally isn't...
<Smerdyakov>
whatsup103, what do you mean?
<Smirnov>
so callcc just evaluates the body right away, and whatever gets thrown to k is the value that is the end?
ChoJin has joined #ocaml
mbishop has quit [Remote closed the connection]
smimou has quit ["bli"]
<dark_light>
callcc is a really weird thing :o
bluestorm has quit ["Konversation terminated!"]
MisterC has quit [Remote closed the connection]
zak has joined #ocaml
twobitsprite has joined #ocaml
<twobitsprite>
man... I wish it was possible to do magic print debugging in ocaml
<zak>
the ocaml object system *looks* like it supports prototype based OO to some extent [not addSlot: and crap, but at least being able to create an object with it's own methods and crap without having to make a class for it] - is this correct?
<zak>
twobitsprite: yeah - i miss that from scheme :(
<zak>
[assuming you mean being able to print a bunch of randomly typed values]
<twobitsprite>
zak: yeah
_ziggurat has quit ["Leaving"]
<twobitsprite>
I miss that from haskell
<twobitsprite>
or, I guess I just miss the polymorphism of haskell
<zak>
i've never used haskell
<zak>
it just looks like a more confusing, slower and pure functional ML... none of which really appeals to me
<twobitsprite>
zak: it's not really that slow
<twobitsprite>
some parts are fairly confusing, but it's mostly in the way its documented
<twobitsprite>
one of the most unfortunate aspects of functional programming, is that all of these math folks get a big head using all thier math jargon and try to make everything sound more spectarular and complex than it is
<zak>
yeah, but [afaik], it doesn't allow as much optimization as [oca]ml - if you code naturally in either language i'd imagine you'd get similar results, but you can code like C in ocaml for speed sensitive parts
<twobitsprite>
it's not horrible... I mean, it /is/ slower, but not nearly as bad as say Python or java...
<zak>
yeah
<twobitsprite>
but it is nice being able to drop down to imperativity when necessary
<zak>
not that java's especially slow these days [more than makes up for it in memory usage though]
<twobitsprite>
yeah, the whole JIT thing has helped out a lot, but the JIT only helps in certain circumstances
<twobitsprite>
i.e. if your program doesn't run for a long time and call the same function over and over, then JIT can be more of a stumbling block...
<twobitsprite>
you can spend more time compiling than running
<zak>
yeah
<zak>
plus bytecode is generally more consise in RAM
<twobitsprite>
yeah
<zak>
smalltalk generally feels like it's running much faster than Java - it's probably really at least 10x slower... i don't understand how Java screwed up so badly with memory management
<twobitsprite>
yeah, I dunno
<zak>
i mean both ocaml and D are garbage collected, and seem to get better memory usage than C++ on the shootout - not to mention smalltalk being almost the same as Java but higher level and with more features, yet still having such efficient garbage collection
<zak>
i used to think Mono was doing fairly good with memory management, until i tried the latest MonoDevelop :s
<twobitsprite>
hehe... never used it
<twobitsprite>
mono is the open source .net stuff, right?
<zak>
yeah
<twobitsprite>
yeah, I don't like the whole .net thing for some reason
<zak>
i quite like it really... gives a chance for "exotic" languages like our beloved OCaml [in the form of F#] and SmallTalk and such to be used alongside "conventional" languages like C# and Java and *grabs vomit bucket* BASIC
<zak>
i mean - it's a microsoft thing - and that makes it a touch horrible - but it seems like a good concept
<zak>
i hope Parrot will take off - but since it's mostly aimed at scripting languages, it might not accomodate ML and such with .NET-ish speed
<twobitsprite>
yeah... but isn't .net all virtual machine stuff? I.e., all bytecode?
<zak>
well, JIT bytecode
<twobitsprite>
right...
<zak>
it doesn't get too bad performance... i think Mono would lag behind Microsoft's though
<zak>
and [at least with Mono] you can pre-compile things too
<twobitsprite>
does F# deviate from the Ocaml standard at all?
<Smerdyakov>
There is no OCaml standard.
<zak>
i'd imagine so... there's a standard?
<twobitsprite>
Smerdyakov: whatever, you know what I mean... does it coincide with the reference implementation
<twobitsprite>
yeah, I noticed that the other day... was surprised
<zak>
seems a bit *insert whatever the opposite of consise is* though
<twobitsprite>
verbose?
<zak>
that's the one
<twobitsprite>
I've never used eiffel, but I never thought performance was one of thier design goals
<twobitsprite>
Smerdyakov: if you're still there... I'm trying to figure out why my yacc/lex generated program isn't running its main function...
<Smerdyakov>
twobitsprite, I don't understand what that means.
<twobitsprite>
i.e. I link my lexer and parser .cmo's to a main.cmo which has a "let _ = main ()" and main has "print_string "foo"" right at the beginning, but I never see it, and it just print "State 0: shift to state 1" and sits there
<zak>
eiffel seems *far* too theoretically oriented - it seems to force upon you a lot of Ultra Long Definitions For Everything (TM) and Design By Really Really Big Long Contract (TM) things that apparently lead to productivity, but i really doubt there's research to back it up
<twobitsprite>
zak: well, they're obviously doing something right :P
<twobitsprite>
Smerdyakov: still confused?
<Smerdyakov>
twobitsprite, you found some flag which makes ocamlyacc parsers print things?
* zak
is sorta tempted to try eiffel anyway
<twobitsprite>
Smerdyakov: er...?
<Smerdyakov>
twobitsprite, why would your program print "State 0: shift to state 1"?
<twobitsprite>
I dunno
<twobitsprite>
that's a good question
<twobitsprite>
would you like to see my code?
<Smerdyakov>
twobitsprite, no. Have you followed the example in the ocamlyacc/lex documentation on how to actually run your parser?
<twobitsprite>
hmm... I can't seem to find a pastebin that works
<zak>
heh... shows it's popularity - there are 6 people in #eiffel - and one of them's me.
<Smerdyakov>
zak, no, that shows its popularity among Freenoders.
<twobitsprite>
I'm following some tutorial, but I've changed enough stuff around that it's compiling instructions don't line up, etc
<zak>
Smerdyakov: yeah, but eiffel's publicity can exadurate all they like, so i can too :)
<zak>
sorta screwed that sentence up a bit, meh.
<twobitsprite>
Smerdyakov: you mean, something like "Parser.main Lexer.token lexbuf"
<twobitsprite>
that's basically what I'm doing
<Smerdyakov>
twobitsprite, OK.
<Smerdyakov>
twobitsprite, well, if you put your code up somewhere, I or someone else might feel like looking at it.
<twobitsprite>
also, something strange: ocamlc likes to puke a bunch of "State 7: shift to state 342" kind stuff all over my screen when it's compile my code...
<twobitsprite>
I don't recall that happening last time I used ocaml a while ago
<zak>
i know there are some patches, but they're out-dated, unmantained and unsupported
<twobitsprite>
bacl
<twobitsprite>
er, back
<twobitsprite>
wait, nm
<twobitsprite>
don't even look at that, I know what it is...
<zak>
what was the problem, out of interest?
<twobitsprite>
It's reading from stdin...
<twobitsprite>
<-- idiot
<twobitsprite>
that's what I get for hacking things up from multiple examples and tutorials...
<zak>
heh
<zak>
it suddenly occured to me that i don't actually have ocaml installed at the moment
trebron has joined #ocaml
<twobitsprite>
zak: heh... I hate when I do that... got a nice new peice of code, eager to see the spew syntax errors at you, and... damn, no compiler
<zak>
i just re-installed linux [what is it with debian? i can't seem to go 3 months without apt getting cancer]
<twobitsprite>
I've never had many problems with apt...
<trebron>
Hello, while reading some ocaml code I came across defining record types as optional; I was curious how this is used when working with the records - and my googling has not really answered any questions. Writing a parser, I'm getting errors similar to: This expression has type Ast.stmtAst option but is here used with type Ast.stmtAst; Makes sense, but not sure what the idioms are for checking whether the field was used before
<trebron>
evaluating. Suggestions?
<twobitsprite>
sounds to me like something is returning an option where a stmtAst is expected...
<Smerdyakov>
trebron, you may be confused. 'option' types have nothing to do with records.
<twobitsprite>
ahh, yeah, "option" does have an unfortunate name, I suppose, for that very reason
<twobitsprite>
trebron: in the top-level type "Some 4;;" and then "None;;" and you'll see
<trebron>
Smerdyakov: correct; let me try to rephrase, here's an IF record:
<trebron>
ifRec = {
<trebron>
ifCond : expAst;
<trebron>
ifThen : stmtAst;
<trebron>
ifElse : stmtAst option }
<trebron>
translateStmt level a.ifThen <-- that works
<trebron>
but if I try something similar with a.ifElse it dies
<twobitsprite>
trebron: I still think you have the meaning of the word "option" confused...
<Smerdyakov>
trebron, yes, and the type message tells you why.
<Smerdyakov>
trebron, there are no automatic type coercions in OCaml. Two types that don't syonym-expand to the same thing can never be used interchangeably.
<twobitsprite>
if translateStmt is expecting a "stmtAst", then a "stmtAst option" will not do
<Smerdyakov>
trebron, it's not a special language feature, so you shouldn't need any Englsh documentation of what it is. The OCaml code there completely defines it.
<trebron>
ok, so it just adds "None" as another possible match, along with 'a?
<Smerdyakov>
No.
<Smerdyakov>
Clearly you haven't made an effort to learn the OCaml language.
<zak>
Smerdyakov: a bit harsh - pattern matching and such is a bit hard to grasp coming from languages like C
<Smerdyakov>
zak, I have a feeling he is guessing instead of misinterpreting documentation that he has read.
<ChoJin>
twobitsprite, do you know Std.dump from extlib?
<twobitsprite>
ChoJin: no...?
<twobitsprite>
I assume you are refering to my complaint about not being able to print random data...?
<ChoJin>
yes :)
* twobitsprite
scores
<twobitsprite>
cool... I'll have to check it out
<ChoJin>
I'm using that now instead of all the string_of... it's so much more convenient
<ChoJin>
it prints lists, record and so on as well
<ChoJin>
very cool :)
<twobitsprite>
sweet... how do they accomplish that?
<trebron>
Smerdyakov: right... well, maybe I'm guessing, but I'm not doing it out of laziness if that's what you're implying. This is how I understand the documentation, and obviously I'm wrong, but that's no reason to belittle my attempts. Here's how I undertand it:
<trebron>
let celse =
<trebron>
(match a.ifElse with
<trebron>
| None -> []
<trebron>
| (Ast.stmtAst e) -> translateStmt level e) in
<twobitsprite>
isn't extlib writen in ocaml, or does it extend the parser, etc?
<ChoJin>
didn't check the code, sorry, I guess I was being lazy on this ;)
<whatsup103>
can someone help me with the CSV stuff ?
<twobitsprite>
trebron: change the "(Ast.stmtAst e)" to "(Some e)"
<Smerdyakov>
trebron, which documentation have you read?
<twobitsprite>
trebron: "option" has two variants, "Some x" and "None"... the "Some" variant holds a value, which will be stored in "e" after the match
<trebron>
twobitsprite: thank you, now I understand what the Some 'a was referring to, and the type inference makes more sense
<Smerdyakov>
trebron, if you haven't read some section of the manual on the OCaml language (as opposed to the standard library), then it is not appropriate for you to be doing what you are doing yet.
<ChoJin>
why do you have to be so harsh?
<ChoJin>
he's just learning
<whatsup103>
i am still thinking of a method to use GRRRR
<trebron>
twobitsprite: much appreciated, thanks a lot
<twobitsprite>
trebron: no problem...
<twobitsprite>
trebron: you probably should read more of the documentation though
<whatsup103>
i need ot re arrange a few columbs in a csv
<whatsup103>
to*
<twobitsprite>
trebron: it's fairly concise, and you'll get better responses from the people in this channel when you ask questions and at least display enough knowledge to show that you have read the docs...
<whatsup103>
now i just need ot figure out what to do with my CSV
<trebron>
twobitsprite: I apologize if it seemed I had no intention of reading the docs - this is not my stance whatsoever; but from the newcomer's point-of-view, it should have been sufficient to point out my need for reading a specific doc without the additonal comments, eh?
<whatsup103>
what do you guys thinnk if harder C++ or Ocaml
<ChoJin>
quite frankly sometimes the ocaml's doc are really obscure
<dark_light>
how can i implement a case-insensitive hash table? like the real hashtable, but like, Hashtbl.find_insensitive x "var" and Hashtbl.find_insensitive x "VAR" returning the same value
<twobitsprite>
trebron: I'm not going to take sides, I'm merely making recommendations to you, esp. being as you are the one seeking something. Smerdyakov doesn't loose sleep if you leave the channel because you are offended, however you are seeking information, so I was merely recommending a method which would serve you better
<dark_light>
whatsup103, C++ is harder for me, because I have to type more code (and uglier code)
<Smerdyakov>
trebron, I advise that you read the entire language tutorial in the manual before writing/reading any more code.
<whatsup103>
hardest thing for me to learn was recursive functions
<whatsup103>
dark_light: how about C ?
<zak_>
whatsup103: coming from C or Java, C++ will be much more familiar - but that's no gauge of which one is "harder"
* dark_light
thinking in simply making a module derivate from Hashtbl that every add/remove adds/removes strings in lowercase, and the find just searchs strings in lowercase
<ChoJin>
dark_light, I'm not familiar with hashtbl from ocaml, but can't you just call String.to_lower?
<twobitsprite>
"hard" is not a very good metric to describe programming languages
<dark_light>
ChoJin, yes i can :)
<whatsup103>
zak_: i was just wondering ........i know ceertain parts of ocaml quite well
<dark_light>
whatsup103, ocaml generally seems easier because the code looks more "what you want" (for me), but for some kinds of programs C is easier to write/read (like: read/print programs or array manipulating programs)
<whatsup103>
dark_light: its all programming preference i guess
<whatsup103>
Lua rulezzzz
<dark_light>
whatsup103, but some C programs just don't looks like "what you want", but instead is a obscure version of the thoughs of the programmer, what is bad (but sometimes necessary)
<ChoJin>
dark_light, it seems you have a functioral version of the hashtbl where you can provide your hash function
<twobitsprite>
I just hate function pointers :P
<ChoJin>
dark_light, thus, if you use that, you could provide your own case-insensitive hash function
<dark_light>
whatsup103, yeah! i find functional programming generally easier to understand
<dark_light>
ChoJin, hmmmmmmmmmmmmm
<whatsup103>
dark_light: i dis agreee ...........i hate recursive functions and they are slower
<whatsup103>
looping is faster then using a recursive function
<twobitsprite>
I've never noticed performance impacts when using recursion
<dark_light>
whatsup103, no, they aren't slower, and recursin isn't the best example of functional programming (my best example is "map" functions, like List.map)
<zak_>
whatsup103: C++ is more restrictive, and generally involves more thought [memory management, type declarations]... ocaml tends to get in your way less - and does more things for you...
<dark_light>
ChoJin, yeah but the hash isn't meant only to speed-up the find?
<ChoJin>
whatsup103, it depends, if the function is tail recursive, the compiler will change your code to a loop
<whatsup103>
i benchmarked and many people in here have benchmarked and it was also on the mailing list ...........they all said it was slower then looping ;)
<zak_>
whatsup103: not really... it really is just looping... if you use recursive functions in C or C++ it is slower - because they're not [usually] optimised for it
* dark_light
always tries to make tail-recursive functions
<whatsup103>
well i just like my loops :D
<twobitsprite>
whatsup103: can you show me where in the mailing list happened? I feel like a significant part of the context is being left out
<dark_light>
whatsup103, yeah :D
<whatsup103>
twobitsprite: its there...........like 6 months ago i spammed the mailing list with questions every 20 mins :)
<ChoJin>
dark_light, a hash table is a sort of array (well it depends how you implement it). For the simple implementation, for a given element x, you compute hash(x), and you store it in the array at this index
<zak_>
unless there's something stopping the compiler from turning it into a loop, it will produce fairly equivalent code
<twobitsprite>
whatsup103: that hardly narrows it down for me...
<dark_light>
ChoJin, my vision of a hash table is: the hash points to a associative table with all elements of same hash. so if i want to find something, i calculate the hash, then go to the associative array of that hash, and find what i want to find (if there are any thing there)
<ChoJin>
dark_light, thus, if you provide a hash function which is case insensitive, it will return the same hash value, and therefore be stored at the same place in the hash table. Same will happen when you do a find
johnnowak has joined #ocaml
<whatsup103>
twobitsprite: im not going ot go find it but its there try a few keywords i dunno .........i mean why would i lie about something so stupid ........use your recursive functions they are fine .......speed doesnt even matter about something like that really ........i just use loops casue thats what i have always used
<dark_light>
ChoJin, because for all hash functions, there are collisions, so if i want a strictly different storage, any hash table would be sufficient for me
<zak_>
whatsup103: have a look at some asm code that does loops - it is just tail recursion - something along the lines of .myloop: code here ..... jmp myloop
<whatsup103>
( is just saying what he has been told)
<whatsup103>
and asm loops are not exactly like recursive functions either
<ChoJin>
whatsup103, I recently looked at asm produced by ocamlopt on tail recursive function. It does generate simple loop
swater_ has joined #ocaml
<zak_>
whatsup103: and in most cases, a normal loop and a recursive function will both wind down to that anyway [unless the function isn't able to be optimised as such]
<dark_light>
well the point is, when you want write a loop, it's better to write a loop. but recursion is more pleasant to me. :E.
<whatsup103>
dark_light: freedom of choice :D
<zak_>
both are useful to me
<ChoJin>
sometimes writting the function as a tail recursive function is more natural, and will be as efficient than doing a loop
<twobitsprite>
damn... I wish sourceforge offered MD5's... I just downloaded extlib and tar complains about a "lone 0 block"
<ChoJin>
just take whatever is more natural to you. For example, I definitely use loop to iterate over arrays
<zak_>
if you're changing structures a lot [ie you're writing imperitive code], it's easier and probably clearer to use a loop, but in most cases, recursive functions are much neater
<ChoJin>
twobitsprite, never got that :)
<dark_light>
sometimes i like Array.iter to iterate over arrays, but for is definitively convenient
<twobitsprite>
ChoJin: yeah... odd... and tar returned 0, so it obviously doesn't consider it an error
<ChoJin>
tar xvzf didn't do it?
<zak_>
although i still think in terms of scheme [where recursion is all you have], so i probably use recursion in many cases when a loop is clearer
<twobitsprite>
ChoJin: well... zxvf seems to extract about 20 files, then at the end says "tar: A lone zero block at 636" and exits with retval of 0
<dark_light>
actually i use much the construct: Array.iter begin\n .. fun x ->\n .. my code\n end my-array, but for sometimes is very good-looking
<ChoJin>
zak_, I think recursion is not natural for a lot of people, but you get used to it ;) Also, for some problem, it _is_ more natural. Like the hanoi tower :)
<twobitsprite>
cygwin seems to do some strange stuff every now and then, though...
<ChoJin>
twobitsprite, try to download it again, maybe it got corrupted... who knows
<twobitsprite>
ChoJin: yeah, same thing
<twobitsprite>
which is why I wish there were MD5's on sf.net
zak has quit [Read error: 110 (Connection timed out)]
<zak_>
<zak_>
ugh
<zak_>
coffee + keyboard = bad
<zak_>
cleaning it with your knee = worse
<twobitsprite>
why does ocaml constantly bombard me with all this "State 10: shifting to state 42" crap whenever I run any ocaml program?
<twobitsprite>
it does it when I run "ocaml install.ml" in the extlib directory...
bebui has joined #ocaml
<twobitsprite>
maybe I think I just need to get my linux box running again and get off of cygwin...
<dark_light>
you are under cygwin? ah
<ChoJin>
twobitsprite, did you enable a debug env variable? :)
<twobitsprite>
zak_: lol... I'm trying to visualise how you are cleaning it with your knee
<zak_>
yeah i'd recommend that
<ChoJin>
i'm doing ocaml under mac and it works like a charm :)
<zak_>
twobitsprite: i figure jeans are pretty absorbent
<ChoJin>
I'm planning on buying a mac mini to be able to compile for other platforms :)
<dark_light>
zak_, you recommend someone cleans the keyboard with the knee?
<ChoJin>
unless someone know how to cross compile for windows from a mac...
<dark_light>
ChoJin, wine?
* zak_
wants a man. send him a mac.
<twobitsprite>
ChoJin: ahh! you guessed it... I forgot I did that the other day... Someone recommended and I didn't know what it was supposed to do :P
<ChoJin>
dark_light, nah :)
<zak_>
oops
<zak_>
god that came out wrong
<zak_>
MAC
<ChoJin>
I don't get why it isn't already supported
<zak_>
NOT GAY. MAC
<ChoJin>
I mean it's a compiler ... so why can't we _easily_ cross compile
* dark_light
happy with his linux box (actually ubuntu edgy)
<ChoJin>
cross compile both for the arch and the OS
<ChoJin>
when I was under intel linux, I wanted to cross compile for intel windows, seemed to be impossible to achieve
pango has quit [Remote closed the connection]
<ChoJin>
so I guess I'll have to buy a mac mini if I want to be able to compile for linux,windows,mac
<ChoJin>
zak_, lol
<twobitsprite>
what directory should I install extlib to? /usr/lib/ocaml?
<dark_light>
ChoJin, i can cross-compile here with wine
<dark_light>
well, it isn't actually cross-compile, but..
<dark_light>
you got it :)
pango has joined #ocaml
<dark_light>
twobitsprite, i think /usr/lib/ocaml/version/
<zak_>
or, you could buy me a mac mini, and i'll consider cross-compiling some stuff for you
<dark_light>
ahahahahahahha
<ChoJin>
yeah, I was in the same position before, now I really need to cross compile. I'm under mac G4, so I need to cross compile to intel, and windows at the same time ;)
<whatsup103>
raise your hand if you know hwo to manipulate a CSV list
<dark_light>
ChoJin, i don't meant implementation, but.. the whole idea
<whatsup103>
caps
<whatsup103>
oops
<ChoJin>
dark_light, because usually when you have collision in a hash table, you do chain list or stuff like that
<ChoJin>
dark_light, but in ocaml, it seems that the last one always overshade the existing one
<ChoJin>
dark_light, check the doc, the "add" function
swater has quit [Connection timed out]
<ChoJin>
dark_light, there is a lot of different way of doing a hash table. Each implementation giving differents property
<ChoJin>
whatsup103, and? :)
<ChoJin>
whatsup103, hurry up, I have to go to the mall to try to find my missing gifts ;)
<dark_light>
ChoJin, so a different key that has the same hash than a currently added binding, will be treated as "previous binding"?
<whatsup103>
lol
<whatsup103>
each list there is a row
<whatsup103>
i am trying to switch them up ........list each list has a A B C i am trying to make each list be in order as like C B A
<ChoJin>
dark_light, yes
<ChoJin>
i don't know why in ocaml implementation they decided to overshade previous binding
<dark_light>
ChoJin, you are *sure*? this is a very bad news for me
<ChoJin>
usually you can see all the values, even when you have collision, not in the std lib apparently
<ChoJin>
val add : ('a, 'b) t -> 'a -> 'b -> unit
<ChoJin>
Hashtbl.add tbl x y adds a binding of x to y in table tbl. Previous bindings for x are not removed, but simply hidden. That is, after performing Hashtbl.remove tbl x, the previous binding for x, if any, is restored. (Same behavior as with association lists.)
<dark_light>
but previous bindings for x is the same thing as "previous bindings that has the same hash as x"?
<ChoJin>
val find_all : ('a, 'b) t -> 'a -> 'b list
<ChoJin>
Hashtbl.find_all tbl x returns the list of all data associated with x in tbl. The current binding is returned first, then the previous bindings, in reverse order of introduction in the table.
<ChoJin>
good news, find_all looks for them all :)
<dark_light>
ChoJin, if i have a simple ((int * int) * int) Hashtbl.t, i can't assume that all possible keys will be representable in the hash table (because there are collisions)
<ChoJin>
dark_light, mmm, good question
<ChoJin>
I don't know
<dark_light>
erm, ok
<ChoJin>
I would have to check the code to see if they consider the hash value or the element itself
<dark_light>
it consider the element
<dark_light>
ahm
<dark_light>
i think it's implemented in a non-intrusive way that considers two keys of same hash really different
<dark_light>
it's the way i assumed
<pango>
of course
<ChoJin>
yeah maybe, I don't know.
<pango>
it's just that buckets are elements lists, and "add" put the new element at the head without checking if the key already exists
<ChoJin>
dark_light, I guess it makes sense, then you probably just need to call String.to_lower ;)
<pango>
find will report the first element found, hence the last inserted (for a given key)
<ChoJin>
pango, yes, but if x and y has the same hash value, they will go in the same bucket
<dark_light>
ChoJin, yeah :) i will just make a derivate module from Hashtbl, overloading find, add, rem..
<ChoJin>
imagine you insert x and y, same hash, so same bucket
<dark_light>
Hmmmm
<pango>
and ? the hash is only used to restrict search, but elements are always compared by key
<dark_light>
ah
<ChoJin>
pango, so when you do find, it search for the first one in the bucket with the same key?
<ChoJin>
but it doesn't always blindly take the first element?
<pango>
so collisions are just a performance issue (if any)
<pango>
of course not, all hash tables (but those using "perfect" hashing) will have collisions
<ChoJin>
yes, but some implementation of hash table could consider collisions as a same key
<ChoJin>
there is probably application for that :)
<pango>
for that you can use a simple array, no need for a hash table
* whatsup103
still deosnt know what to do
<ChoJin>
whatsup103, because you don't explain your problem, you keep whining about it, but don't explain what it is :)
<pango>
unless you want both hash aliasing, and queue behavior ? strange datastructure...
<pango>
s/queue/stack/
<whatsup103>
lol
<pango>
whatsup103: I have a hard time believing you could have missed lists if you seriously read any tutorial on OCaml in the last months
<whatsup103>
ChoJin: i have a csv file loaded its a sting list list ..........each string list is a row thats the horizontal thing as shown here http://phpfi.com/185225 each list is a row ..........now
<whatsup103>
i just dont know how to alter each colum
<ChoJin>
alter how?
<whatsup103>
move around
<pango>
whatsup103: lists are immutable
<stevan>
whatsup103: I would normalize that csv first
<stevan>
you dont need the header in there wheen you are processing it
<ChoJin>
you don't have the same number of column in each row (it seems)
<stevan>
your second row seems to be headers, and has an extra item in it
<ChoJin>
yeah the header sucks :)
<stevan>
I would loose all the rows which are not data
<stevan>
cause you will end up having to code around them.,.. and that is silly
<whatsup103>
i dont get it
<stevan>
once you do that,.. it should be easy to process this data anyway you want
<whatsup103>
its a fine cvs
<whatsup103>
i just opned it up in Kspread
<stevan>
yes, nothing wrong with the csv
<stevan>
but you have rows in there which I doubt you want to process
<stevan>
whatsup103: *how* do you want to process it, that might help
<whatsup103>
its just 2 colums
<stevan>
maybe show us what you want the finished product to be
<whatsup103>
i do
<whatsup103>
what rows
<whatsup103>
everything is full ?
<stevan>
whatsup103: if we dont know what your goal is, it is hard to help you get to it
<ChoJin>
get_nth_column n = List.fold_right (fun i acc -> List.nth csv n::acc) csv []
<ChoJin>
or something like that ;)
<whatsup103>
wait wait
<whatsup103>
im making this sound waaay more complicated
<whatsup103>
pretend this
<whatsup103>
i have 8 colum spreadhseet NOT rows
<stevan>
ok
<whatsup103>
and i want to move colum 2 to colum 8 ant colum 8 to colum 3 etc
<whatsup103>
i mean
<whatsup103>
colum 2
<whatsup103>
switch them
<stevan>
yes,.. tat makes sense now
<whatsup103>
:)
<whatsup103>
thats all i want
<whatsup103>
basically this is a spreadhseet of a companys inventory
<whatsup103>
and i have to move things around to get it to work with a Bulk uploader for a shopping cart
<whatsup103>
understand now ?
<stevan>
yes
<whatsup103>
so im not altering just relocating colums
<whatsup103>
and all that thing i shoed you was a small test ...........the real csv is like 8.2 MB
<ChoJin>
convert your list of row, to a list of column, then switch :)
<whatsup103>
and i just used the csv library to load the csv
<stevan>
whatsup103: what csv library
<pango>
ChoJin: could have used List.map instead of a fold
<whatsup103>
its the only one arounf
<whatsup103>
d*
<stevan>
whatsup103: yes, but i dont know it, so please link to its docs
<stevan>
this will make it easier to do the column moving
<whatsup103>
then what
<stevan>
whatsup103: ok,.. then you basically want to map over the rows
<stevan>
Array.map (or whatever it is)
<stevan>
for each row, you construct a new array
<whatsup103>
could i just use List.map ?
<twobitsprite>
ChoJin: I wouldn't have any idea... I didn't even think something like dump was possible in the first place, so I didn't know what to expect
<stevan>
whatsup103: its not a list anymore, its an array
<pango>
ChoJin: yes (you just forgot the column number)
<whatsup103>
but right now its in string list list
<ChoJin>
yeah, an array is probably easier to use for this case
<stevan>
whatsup103: if you want to do random access (which is the simplest way to switch the columns) then an array is more efficient
<ChoJin>
I don't like list anyway ;)
<stevan>
lists are great if you are not doing random access :)
<whatsup103>
i seeeee
<whatsup103>
grrrr
<whatsup103>
so its not possible to do in regualr list form ?
<stevan>
it is,.. just insanely inefficient
<whatsup103>
i seee
<pango>
I see no point in using an array at all (nor in loading the whole csv to start with, since the library allows to read one line at a time with a HoF)
<whatsup103>
HoF?
<pango>
stevan: but you can do all permutations and selections at once with pattern matching
* whatsup103
is now all confused
<stevan>
pango: your right,.. I didnt see the Csv.load_rows
<pango>
whatsup103: high order function
<stevan>
whatsup103: Csv.load_rows will basically map over each line of the file
<whatsup103>
oooo
<whatsup103>
i didnt see that either
<whatsup103>
but how will i switch order of the colums
<stevan>
whatsup103: do you have a fixed number of columns?
<whatsup103>
and after eaxh row it will write to the file ?
<whatsup103>
yes yes
<whatsup103>
its like 10
<whatsup103>
i have a cvs product inventory file with 10 colums :D i just want to move the colums around :)
klapmuetz has quit ["Lost terminal"]
<stevan>
whatsup103: honestly,... you could have done this in like 1 minute in excel :)
<pango>
whatsup103: btw, how do you plan to inject the data into your database ?
<whatsup103>
yea but it needs to be autoamted :)
<stevan>
whatsup103: a perl script would have been just as simple too
<whatsup103>
pango: i am moving around to fit the structure of the shopping carts Bulk uploader
<stevan>
ocaml is fun, but kind of silly for this task to be honest :)
<whatsup103>
i just ran into the csv loader so i took it for whats it worth
<pango>
whatsup103: that didn't answer my question, though
<whatsup103>
huh ?
<pango>
you're generating another csv ?
<whatsup103>
yes
<pango>
mmh ok
<whatsup103>
load this csv change row order write another CSV ........go into shopping cart upload csv
<whatsup103>
yipE
<whatsup103>
thats my goal anyways
<whatsup103>
i could do it in php in 5 minutes
<stevan>
whatsup103: you want to process each row in the CSV with something like this
<stevan>
fun one::two::three::four::five::six::seven::eight::rest ->
<stevan>
although not sure if that switches the columns exactly
<whatsup103>
:)
<stevan>
like you said
<whatsup103>
something like that yea
<stevan>
but the pattern matching (like pango said) would be the way to go
<stevan>
whatsup103: then you probably need to print that to your own filehandle too
<whatsup103>
i would just use php but since the guy is paying me 700.00 to do it i thought i would use something a little more time consuming
<stevan>
because it looks like the higher order function you pass Csv.load_rows expects a unit return type
_velco is now known as velco
<pango>
your whole program can be written in just one line, so OCaml isn't that bad for the task ;)
<stevan>
whatsup103: well if this somehow prevents more PHP code from being written.. then the world is a better place :)
<pango>
only headers get in the way
<whatsup103>
pango: yea well all i have done in ocaml is network and gui and like some if statements
<whatsup103>
ala im client
<whatsup103>
:D
<whatsup103>
pango: i submitted ot the gtk devel list about the epoll .........they said they are implmenting epoll in gtk right now and of course where epoll is not avaliable it will use poll
<whatsup103>
so i get to use the overkill after all
<pango>
so you need 3 or 4 lines instead
<whatsup103>
huh?
<ChoJin>
damn 700$ for that? :)
<ChoJin>
I need job like that too ;)
<whatsup103>
heh
<whatsup103>
i wanted to put a little more effort in it
<whatsup103>
then just throw a 5 min php script in
* stevan
would have taken 10 minutes and written it in perl then surfed for a few hours before turning it in
<ChoJin>
I wish my 5min was worth 700$ :)
<whatsup103>
lol
<whatsup103>
i have only worked on it for like what
<whatsup103>
30 mins
<whatsup103>
off and on
<whatsup103>
but it is feeeidng his whole product database so that just sounds like alot
<whatsup103>
it was 1,000 but he jew'd me down pretty good
<twobitsprite>
score!
<twobitsprite>
I now have a functioning semi-optimizing brainfuck interpreter! :)
<whatsup103>
im about to refine my im client optimize it make sure its perfect and sell it to this guy for 4,500 usd
<whatsup103>
he thinks im making it from scratch
<whatsup103>
pango: so pattern matching will do this ?
<pango>
whatsup103: hardcoded columns reordering is piece of cake, it would be more fun to adapt to actual columns names in input ;)
<ChoJin>
twobitsprite, lol
<twobitsprite>
ChoJin: :)
<ChoJin>
twobitsprite, check extlib now that you have downloaded it, there is a lot of useful stuff
<twobitsprite>
ChoJin: yeah, I'm looking through it now... I've seen it before, but never messed with it much
<twobitsprite>
who'd have thunk it would take 1,040 lines of code to make a brainfuck interpreter :P
<ChoJin>
ok, i have to go to the mall... hate it, but I need to find gifts :)
<twobitsprite>
(of course, I went all out and used yacc/lex, etc...)
ChoJin has quit ["This computer has gone to sleep"]
akrito has joined #ocaml
johnnowak has quit []
akrito has left #ocaml []
swater_ has quit ["Quat"]
gaja has joined #ocaml
<whatsup103>
twobitsprite: shoudn't as interpreter be made in like .........ASM or something
<whatsup103>
pango: im working on doing the colum re ordering now .........what should i use again load_in and like do some kind of pattern match and at the end of each read just write the new thing ?
malc_ has quit ["leaving"]
zak_ has joined #ocaml
esdee has left #ocaml []
ziggurat has joined #ocaml
zak has quit [Read error: 110 (Connection timed out)]