<MegaWatS>
you DID input an end-of-file after your test input?`
<whee>
of course :P
<whee>
using open_in and Lexing.from_channel to read from file
<whee>
I know that at least works because I used the same code in one of my previous programs
<MegaWatS>
what exactly kind of unwanted behaviour does your program exhibit?
<whee>
it's looping with 100% cpu usage once I try to parse input with the parser
<MegaWatS>
your test input came from where?
<whee>
some site with a bunch of examples of bf programs
<MegaWatS>
no i meant, from a file, a pipe, console etc
<whee>
oh, file
<MegaWatS>
but that probably means a file which is just as well :)
<whee>
heh
<MegaWatS>
anyway you should probably eliminate that left-recursion in your first rule
<MegaWatS>
but it would really be a BAD sign for ocaml`s yacc if the parser generator didn`t catch that and produced an infinite loop because of that :/
<MegaWatS>
or rather: to be more precise, a bug :)
<MegaWatS>
ie try it with command commands
<MegaWatS>
instead of commands command
<MegaWatS>
how large was your input, anyway?
<whee>
short hello world type
<whee>
this is crazy weird :\
<MegaWatS>
?
docelic has joined #ocaml
docelic has quit [Client Quit]
mrvn has joined #ocaml
lament has quit ["mental mantle"]
mrvn_ has quit [Read error: 110 (Connection timed out)]
MegaWatS has quit ["Don't you hate it when chicks get mad at you for staring at their asses? It's not my fault that they have stuff written there]
j_bravo has quit [Read error: 54 (Connection reset by peer)]
docelic has joined #ocaml
docelic has quit ["Client Exiting"]
<whee>
yikes
<whee>
was thinking of doing an ocaml program for the latest programming fun contest on kuro5hin, don't think I should now
<whee>
some c++ version submitted is 1472% faster than the ocaml version I just wrote, and mine just does parsing at the moment
<whee>
parsing with lex/yacc too heh
<whee>
guess I'll finish and submit anyway, screw the speed :P:
luke has joined #ocaml
luke is now known as _case
<whee>
hrrrm
jemfinch has joined #ocaml
<jemfinch>
O'Caml doesn't have a standard function composition function/operator, does it?
<whee>
but I went and used lex/yacc to parse the words because I don't know how to do that by hand :\
<lament>
hahaha
<jemfinch>
whee: where's your entry?
<jemfinch>
whee...geez!
<whee>
I'm not posting, it's bad :)
<jemfinch>
you just make a simple state machine.
<jemfinch>
whee: do you have a copy of K&R near you?
<whee>
all I do is store all the words in a hash then iterate through that when it's done to get the top ten
<whee>
99% of my time is spent parsing (parsing, not the hash insertion) which is out of my hands anyway
<jemfinch>
did you profile?
<lament>
ummmmm
<whee>
I'm not interested in doing it in C jemfinch, I hate it :)
<jemfinch>
I really doubt 99% of your time is in parsing.
<lament>
the longest word in the top ten is 4 chars long
<jemfinch>
whee: I didn't tell you to do it in C.
<lament>
if you only count words up to 4 chars, is that cheating?
<jemfinch>
I asked you if you had handy a K&R.
<whee>
jemfinch: if I go and remove all the instructions tso the parser does nothing but go through, it spends 4-5 seconds going through the file
<whee>
compared to around 6 if I do the actual work
<SoreEel>
You might consider the flamboyant approach. Write an elaborate program with the strangest and most amusing design that you can conceive of. You will only lose from the pedestrian perspective :P
<jemfinch>
whee: ok.
<jemfinch>
whee: so, you never answered my question :) Do you have a K&R handy?
<whee>
nope
<jemfinch>
oh, darn.
<jemfinch>
they have a good example that shows to write a word counter.
<lament>
SoreEel: in brainfuck, perhaps
<whee>
the perl version of this is rather nice
<SoreEel>
Immediately a program that generates a sound wave based on the frequency of words in the text came to my mind.
<jemfinch>
whee: and there's probably a better data structure for your map than a HashTable.
<whee>
yeah, but that wouldn't be worth it
<jemfinch>
it'd be fun. And that's why you were writing this in the first place, wasn't it?
<whee>
well it works now, so I'm done :)
<whee>
I wouldve continued to play with it if there were a chance of getting it around the same speed as the C entries
<jemfinch>
it doesn't work well.
<whee>
but that won't happen short of rewriting the parsing
<jemfinch>
whee: what's it going to take for you to do it better, me writing a faster version in SML? :)
<whee>
:P
<whee>
unless using regular expressions on strings is faster than yacc/lex, you'd have to write it in assembly :)
<jemfinch>
whee: first, using regular expressions is probably faster than lex/yacc.
<jemfinch>
second, it's still probably faster than writing a simple state machine.
<jemfinch>
s/than writing/to write/
<SoreEel>
Shame that you need to report the exact number of occurances for each word.
<jemfinch>
which is still probably significantly slower than using mmap :)
<jemfinch>
SoreEel: it'd be way to easy otherwise.
<SoreEel>
I wonder what sort of creative algorithms could be used to determine the most common word in a body of text.
<whee>
I think I'll just wait until the next pfc and try that :p
<SoreEel>
Perhaps a program that would have to "guess" inexactly, balancing pure speed with accuracy.
<SoreEel>
And have a number of different undisclosed texts.
* jemfinch
just has fun writing programs.
<jemfinch>
and I'm going to write an SML version that's faster than your O'Caml version :P
<whee>
:P
* SoreEel
just has fun theorizing about writing programs.
<jemfinch>
whee: did you see the code I posted to the mailing list? A better functional version of that ["123", "45", "789"] -> [1,2,3,4,5,6,7,8,9] function?
<SoreEel>
Memory usage could also be criteria for ranking.
<whee>
probably jemfinch
<whee>
how can you keep track of peak memory usage?
<whee>
heh my ocaml version uses half the memory of this c++ one, hooray for garbage collection
<whee>
wonder if that's the problem
<jemfinch>
increase your gc limit.
* jemfinch
will write a python version right quick.
<lament>
i think it was really stupid that they said what text they're going to use
<whee>
yes, me too
<whee>
people went and hardcoded buffer sizes and all, it's pretty lame
<SoreEel>
The challenge itself it rather trivial.
<jemfinch>
they might as well just hardcore the result.
<SoreEel>
Completely lacking in imagination.
lament has quit ["mental mantle"]
lament has joined #ocaml
<whee>
nuts, ocaml.org goes down right when I need documentationj
<SoreEel>
Hmm
<SoreEel>
Counting syllables is at _least_ more interesting.
<whee>
I wouldn't know where to start on that one :P
<SoreEel>
That's why it's more interesting.
<whee>
actually I'd probably find out how TeX does it and rip that off. heh
<SoreEel>
Accuracy would be an issue.
<SoreEel>
TeX does moderately well.
<SoreEel>
I assume you mean for the auto hyphenation... right?
<whee>
yes
<SoreEel>
With our augmented challenge, there are more variables that factor into ranking. Accuracy vs speed. This obviously gives higher-level languages a chance.
<SoreEel>
It could be a "compound" challenge, measuring different aspects of a text.
<whee>
heh this actually works slower if I effectively disable gc
<SoreEel>
Longest sentence, number of syllables.
<jemfinch>
whee: do you want a Python version to compare to your O'Caml version?
<whee>
sure
<jemfinch>
whee: dcc send alright?
<whee>
yes
<jemfinch>
when I get the SML version working, do you want that too?
<whee>
I don't have a sml compiler :|
<jemfinch>
ah, that's too bad.
<whee>
erm well the problem with this python one is that it handles word differently than mine
nkoza has quit [Read error: 60 (Operation timed out)]
<whee>
yours splits on whitespace, the contest wanted A-z 0-9 _ ' as words, everything else ignored
<jemfinch>
hmm.
<jemfinch>
I didn't look at the corpus.
<jemfinch>
and mine's not case insensitive, I forgot that.
<whee>
20.097 seconds with this python one, compared to 8.092 with my ocaml (this is a larger file than the previous as well)
<jemfinch>
so for a word like "Folio/35" do they want the entire word ignored, or what?
<whee>
no, Folio is one word, 35 another
<jemfinch>
how do you know that A-Z0-9_ is a word and everything else isn't>
<jemfinch>
I haven't seen anything like that in the problem description.
<SoreEel>
The results for that particular text are easily foretold-- Finnegans Wake however I wonder.
<whee>
it's somewhere in the huge list of comments
<whee>
there's also something about removing the quote after getting the word but I don't bother doing that heh
<whee>
so that "it's" would be the same as "its" and so on
* jemfinch
needs a benchmarking function in SML/NJ.
<SoreEel>
Would either of you care to find out? ( ftp://ftp.trentu.ca/pub/jjoyce/fwake/ascii_texts/ )
<lament>
heh
<whee>
jemfinch: SML have something to delay computations?
<jemfinch>
whee: any language with first-class functions has something to delay computations.
<lament>
heh
<whee>
you could create a function that takes a suspended computation, gets the current time, does the computation, then returns it
<jemfinch>
datatype 'a thunk = FORCED of 'a | UNFORCED of unit -> 'a
<jemfinch>
whee: yeah, I know :)
<whee>
printing out things along the way
<whee>
jej
<jemfinch>
whee: even in lazy languages like Haskell, thunks are underlyingly implemented that same way.
<SoreEel>
jemfinch, may I have your Python version of the program?
<jemfinch>
SoreEel: let me fix it to be case insensitive.
<SoreEel>
But abide Zeit's sumonserving, rise afterfall. Blueblitzbolted
<SoreEel>
from there, knowing the hingeworms of the hallmirks of habita-
<SoreEel>
tionlesness, buried burrowing in Gehinnon, to proliferate through
<SoreEel>
all his Unterwealth, seam by seam, sheol om sheol, and revisit
<SoreEel>
our Uppercrust Sideria of Utilitarios, the divine one, the hoar-
<SoreEel>
der hidden propaguting his plutorpopular progeniem of pots and
<SoreEel>
pans and pokers and puns from biddenland to boughtenland, the
<SoreEel>
spearway fore the spoorway.
<SoreEel>
I'm unsure if Joyce actually repeats any nonmundane words.
<jemfinch>
you mean someone actually wrote what you just pasted?
<SoreEel>
Yes, he wrote roughly 700 pages.
<jemfinch>
and people think he's the best American author ever?
<SoreEel>
Considering he's Irish, probably not.
<lament>
he's not american
<lament>
but people do think he's the best author ever
<jemfinch>
he sounds like a verbose high schooler with a penchant for attacking the thesaurus :)
<lament>
at least, some people
<SoreEel>
Faulkner is the one you seek.
<jemfinch>
lament: I was going to say "best author ever" but couldn't quite remember what exactly I read.
<jemfinch>
I know I've read that he's the "best ever" something :)
<lament>
well, one of the best, certainly
<SoreEel>
Don't trust any document that explicitly names the "best" anything.
<jemfinch>
and he writes like that example?
<SoreEel>
In Finnegans Wake, yes.
<SoreEel>
I have a channel dedicated to his work, #zozzymusses.
<SoreEel>
It's rather vacant at the moment.
<lament>
jemfinch: fortunately, finnegans wake is not his only work.
<jemfinch>
hehe :)
<jemfinch>
I'm not much of a literarian.
<jemfinch>
I tried to be, once, but I found myself reading authors just to get some quotes to try and impress smart chicks.
<whee>
I find being a dork helps impress smart chicks. That is, until they find out I'm a dork.
<whee>
then it kind of works against me
<jemfinch>
I learned just to use my sense of humor.
<whee>
that doesn't quite cut it for me either :(
<SoreEel>
Finnegans Wake approached from varied perspectives is frustrating... condescending... meaningless... profound... beautiful.
<whee>
my sense of humor is twisted and heh
<jemfinch>
what is a "Finnegans"? Or is it a possessive that's just missing its apostrophe?
<lament>
I have never read finnegans wake.
<lament>
And i probably won't.
<lament>
"The end is the beginning"
<lament>
or something like that
<lament>
and an allusion to finnegan wakes which is something else
<SoreEel>
jemfinch, there is a tradition Irish story of Finnegan, who fell of his roof and was pronounced dead. During his wake, a mourner spills whisky on his lips, and he is revived.
<jemfinch>
ah, so it's a possessive.
<jemfinch>
it's about Finnegan's Wake.
<SoreEel>
It's not that simple.
<jemfinch>
sorry, the lack of apostrophe was getting to me :)
<jemfinch>
it never is with these literary geniuses.
<SoreEel>
Joyce also wanted to insinuate that we are all Finnegans.
<jemfinch>
like that poem by William Carlos Williams.
<SoreEel>
The book is about the unconscious state, dreams.
<SoreEel>
Hence the allusion to waking.
<jemfinch>
oh.
<jemfinch>
how long is it?
<lament>
heh
<lament>
SoreEel: what language is "the end is the beginning" in?
<whee>
english? :)
<SoreEel>
The Penguin edition encompasses 628 pages.
<SoreEel>
My ASCII text file is 1.29 megs.
<whee>
I don't think I'd be able to read this book
<whee>
he just randomly defines words?
<lament>
oh
<lament>
FINN = end
<lament>
EGANS = again
<lament>
WAKE = a) wake up
<lament>
b) Irish death celebration
<SoreEel>
The entire book is written in a portmanteau polyglot dreamspeak.
<SoreEel>
Joyce felt that everyday language could not represent the unconscious state very well.
<jemfinch>
is that a loquacious way of saying, "on crack"?
<whee>
I'll have to agree with the crack.
<SoreEel>
It's a very profound statement on language, and by way of language, a profound statement on thought.
<SoreEel>
What is more powerful, the concept of the book, or the book itself?
<lament>
the crack.
<jemfinch>
well, at 628 pages I'm sure it packs quite a wallop.
<SoreEel>
Have you ever awoken to find a fragmented dreamthought on your mind?
<jemfinch>
what's a dreamthought?
<SoreEel>
Something which a few moments earlier made sense.
<jemfinch>
I've spoken from my subconcious mind before, if that's what you're asking.
<SoreEel>
When analyzed with a conscious mind, a logical mind, is absolutely absurd?
<jemfinch>
sometimes when I'm right on the edge of sleep (the edge on the sleep side, not the waking side), someone will start talking to me, and I'll answer without actually waking up. I'l carry on a conversation with this person completely from my subconscious mind.
<jemfinch>
my girlfriend just loves it. Some of the things I say make no sense whatsoever.
<SoreEel>
The book tries to capture these dreamthoughts.
<jemfinch>
usually the act of speaking wakes me up, and I remember what I just said, and chuckle, but I'll fall right asleep again and do the same thing in seconds.
<jemfinch>
one time, I was falling asleep and someone asked me, "How do black holes form?" and I answered, "It takes a triangle" and was about to go into what seemed to be an entirely coherent and sensical explanation when I realized I had just said, "It takes a triangle" and that realization woke me.
<jemfinch>
so yeah, I understand this "dreamthought" concept, though I can't say that I think it's a language any different from my normal language.
<SoreEel>
Three quarks for Muster Mark!
<whee>
hrm, I think I'll learn camlp4 tomorrow and add that function composition operator
<jemfinch>
good.
<whee>
and maybe one for doing basic timings since I think I would use that a lot
<jemfinch>
I like having one in SML and Haskell.
<whee>
I think I'd have fun if I could replace "some_func blah blah" with "!some_func blah blah" and with the ! it would go and output timing info
<SoreEel>
Hmm.. the dreams of the formless antagonist change throughout the night. At points with thin cover of sleep, he/she ponders aspects of her/his everyday life. Characters in the book being assigned to personalities he knows.. And in deeper portions of his night, the world is recreated, and he/she walks with the titans..
* SoreEel
sighs
* jemfinch
is writing a TST library in SML.
<SoreEel>
Joyce died before he could explain his book.
<jemfinch>
do you think he would have if he'd lived?
<SoreEel>
I doubt he would have, anyways.
jemfinch has quit [Remote closed the connection]
jemfinch has joined #ocaml
jemfinch has quit [Remote closed the connection]
matkor has joined #ocaml
lament has quit ["mental mantle"]
lyn has quit [Read error: 113 (No route to host)]
two-face has joined #ocaml
j_bravo has joined #ocaml
matkor has quit [Remote closed the connection]
two-face has left #ocaml []
asqui has joined #ocaml
<asqui>
Hello boys.
<asqui>
So... on fun vs function, what is the difference again? function can only take one parameter?
two-face has joined #ocaml
zack has joined #ocaml
<two-face>
hello zack
<asqui>
So... on fun vs function, what is the difference again? function can only take one parameter?
<zack>
hi
<asqui>
Hi guys.
<two-face>
function allows you to enumerate possible values for parameters
<asqui>
Oh wait, this fun/function stuff totally different between OCaml and Caml Light isnt it?
<two-face>
i don't recall caml light
<asqui>
Here is what this book says, perhaps you could explain it to me :)
<two-face>
the book explains everything
<asqui>
Which book?
<mattam_>
is there a way to get the same output for expressions as the ocaml interpreter in a standalone program ?
<two-face>
asqui: see topic
<two-face>
mattam_: huh?
<asqui>
oh *that* book
<asqui>
But that book, like this channel, is regarding Ocaml :P
<two-face>
asqui: of course
<mattam_>
two-face: you know, like when you write 'let a = 2;;' it says 'val a : int = 2'
<two-face>
mattam_: i don't think so
<asqui>
I notice the convention of setting out a fun definition with pipes at the beginning of each match line which indent, show clearly what is happening, and obviously also act as a part of the fun syntax... however, no the first line if you have a pipe that is basically: "fun | 0,0 -> ... | x,y -> ... | ..."
<asqui>
I assume this is valid, in which case what is happening? The first pattern is some sort of null pattern that is never matched? Isnt this considered bad practice or something/
<two-face>
what first pattern ?
<asqui>
The syntax of fun is "fun <pattern> -> <expression> | <pattern> -> <expression> | ..." right?
<asqui>
So if you have "fun | ...", asuming it is valid, what it actually translates to is that the first pattern is some sort of null.
<two-face>
i think it allows that any case begins with a pipe
<two-face>
like with "match ... with"
<asqui>
So it is not considered bad practice to have 'fun' immediately followed by a pipe?
<two-face>
no, it isn't
<asqui>
cool
<two-face>
fun | x -> is like fun x ->
<two-face>
bye
two-face has quit ["Client Exiting"]
skylan has quit ["Reconnecting"]
skylan has joined #ocaml
spip has joined #ocaml
spip is now known as spip[pala]
zack is now known as zack_away
zack_away is now known as zack
<whee>
hrm
<whee>
I wonder if existentially quantified types will ever make it into ocaml :|
<whee>
er wait
<whee>
okay nevermind, thought it might work but it doesnt :|
<whee>
trying to fake it with polymorphic variants somehow :|