malc has quit [Read error: 110 (Connection timed out)]
docelic has quit ["ok, done"]
kirb has joined #ocaml
kirb has quit [Connection reset by peer]
kirb has joined #ocaml
<whee>
starting to like haskell. save me
<whee>
(:)
<SoreEel>
Which operator is that?
<whee>
just a smiley face. minus the face :D
<lament>
what's wrong with liking haskell?
<whee>
ocaml will get jealous
<lament>
ouch
<whee>
that already happened to me with my computers :(
<whee>
I used my laptop all summer and now my desktop is broken and I'm too lazy to fix it
<lament>
A hybrid of haskell and ocaml would be a fun language. Or not.
<whee>
I'm starting to really like the whole lazy evaluation thing
<whee>
and haskell's type classes are nice
<lament>
yes, lazy evaluation rules
<whee>
that and list comprehensions look really useful
<lament>
it's fun to have if..then..else as an actual expression
<whee>
eh?
* whee
is still learning :|
<lament>
well, in other languages if..then..else has to be a special form
<lament>
because it only evaluates one of its subexpressions
<whee>
oh I see what you're saying now
<whee>
there's no way to delay the evaluation of it in non-lazy languages
<lament>
yes
<lament>
which is why in scheme, for example, if is not a function
<whee>
can't think of a use for delaying that yet, but I'll get there :D
<lament>
well, in this case it's not really useful, but fun nevertheless :)
<lament>
Heh, list comprehensions are one of the reasons why i like Python so much.
<lament>
(Python stole them from Haskell)
<whee>
python's stealing all the good things
<lament>
yes
<whee>
hope it doesn't get to the point where it's unmaintainable
<lament>
i don't think it will; it remains consistent
kirb has quit [Remote closed the connection]
MegaWatS has quit ["Actually, people sometimes talk about man's "bestial" cruelty, but that is being terribly unjust and offensive to the beasts:]
j_bravo has quit [Read error: 104 (Connection reset by peer)]
j_bravo has joined #ocaml
j_bravo has quit [Read error: 104 (Connection reset by peer)]
docelic has joined #ocaml
docelic has quit [Remote closed the connection]
ElCritter has quit ["Client Exiting"]
lament has quit ["mental mantle"]
graydon has quit ["xchat exiting.."]
mrvn_ has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
mattam_ has quit [Read error: 60 (Operation timed out)]
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
mattam has joined #ocaml
j_bravo has joined #ocaml
<j_bravo>
hello people
<j_bravo>
anyone home?
j_bravo has left #ocaml []
j_bravo_ has joined #ocaml
lament has joined #ocaml
<j_bravo_>
hi
<lament>
hi
<j_bravo_>
is there a way in ocaml of transforming a "while...do" loop imperative style to a rather functional way using pattern matching and recursion in OCAML?
<mellum>
j_bravo_: an automated way, you mean?
<j_bravo_>
well, i dont want to use the while...do loop. Instead I want to uses pattern matching and recursion. Possible?
<mellum>
It should be always possible.
<mellum>
Whether it's more readable depends...
<j_bravo_>
well as long as it's less imperativ...
<j_bravo_>
has anyone had this problem before?
<lament>
any loop can be trivially expressed with recursion
<lament>
and vice-versa
<j_bravo_>
well in my script i expressed the LZW Algorithm via while...do loop.
<j_bravo_>
now i have the problem of transforming it to functional recursion
<j_bravo_>
...
<j_bravo_>
:(
<whee>
j_bravo: is the algorithm inheriently iterative?
<j_bravo_>
id say so ... i can send u the .ml file to look at it if u want to
<whee>
sure
<lament>
j_bravo_: then why do you want to make it recursive?
<j_bravo_>
i just want to see if it works without the while...do loop..make it more functional...no refs...
<whee>
lament: it can at least go into a couple functions that recurse
<whee>
with tail recursion it'll compile to essentially the same code as well
<j_bravo_>
well but it seems to be more complicated tranforming a while...do loop into seperate recursive functions...
<j_bravo_>
let me send u the .ml file
<lament>
whee: it's interesting that Charles Moore, the inventor of Forth and a raving lunatic who wants simplicity at any cost, got rid of all loops and only uses tail recursion
<whee>
heh
<lament>
j_bravo_: all those global variables would have to become function arguments
<lament>
j_bravo_: after that, making the thing recursive will be trivial
<j_bravo_>
mmm...
<whee>
yeah basically
<j_bravo_>
what would be the main function...
<whee>
also, what does this count function do exactlu?
<lament>
j_bravo_: the body of the loop would be a separate function
<j_bravo_>
the count gets the count of the string in the string table and puts it into the code_list...the final code
<j_bravo_>
i have problems expressing the while condition with a function
<j_bravo_>
oh well...
<whee>
if it were a function, what would the main arguments be?
<whee>
(what does it operate on)
<j_bravo_>
it checks if there are if the string_list (the string that is being compressed (transfomed into code_list)) is empty or not...
<j_bravo_>
i could actually do that with pattern matching i think
<whee>
this looks easy to transform, but let me find you an example so you understand :D
<whee>
what basically happens is those references become variables to the recursive function
<whee>
and it looks like you're always operating on the head of the list, right?
<whee>
bleh I can't find examples anymore
<whee>
but if you check list.ml in the ocaml source (ocaml/stdlib/list.ml) you'll see examples of what I'm talking about
<j_bravo_>
k
<whee>
look at rev_map and find_all for example
<j_bravo_>
let me look ar it
<whee>
well maybe find_all is a bad one
<whee>
actually they're both confusing :)
<whee>
but the idea is to use some variable in the inner recursive function that would be your condition in your while loop for example
<whee>
I don't really understand the algorithm so I can't help that much though :|
<whee>
it looks like at least the add_to_table call and code_list var could be done recursively
<j_bravo_>
STRING = get input character
<j_bravo_>
WHILE there are still input characters DOCHARACTER = get input character
<j_bravo_>
IF STRING+CHARACTER is in the string table then
<j_bravo_>
STRING = STRING+character
<j_bravo_>
ELSE
<j_bravo_>
output the code for STRING
<j_bravo_>
add STRING+CHARACTER to the string table
<whee>
lemme write some code that may or may not work
<whee>
heh
<j_bravo_>
cool
<j_bravo_>
;)
<j_bravo_>
hehe
<whee>
what's string_list exactly?
<j_bravo_>
string_list is the string converted into a string list
<j_bravo_>
the string is will be compressed
<whee>
right, but what's the default value represent
<j_bravo_>
through the LZW
<j_bravo_>
default value of string_list?
<whee>
the initial binding you used
<j_bravo_>
sure
<j_bravo_>
thats good
<j_bravo_>
string_table is the alphabet...
MegaWatS has joined #ocaml
<whee>
okay
<j_bravo_>
it is actually really interesting understanding LZW
<j_bravo_>
;)
<whee>
der
<whee>
attempting to do this with pattern matching and the like but I'm not understanding something heh
<j_bravo_>
what is it u dont understand?
<whee>
ah nevermind figured it out
<j_bravo_>
;)
<whee>
but I still don't like this :|
* j_bravo_
i know how frustrating it can be...
<whee>
gah I don't know
<whee>
heh
<j_bravo_>
LOL
* j_bravo_
not really trivial is it?
<whee>
I was thinking of using the Buffer module and doing this but it's still messy how it refers to the new string and the old one
<whee>
I'd rather just have one string to mess around with instead of the two :|
<j_bravo_>
yep
lament has quit [Remote closed the connection]
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
gl has quit [Read error: 54 (Connection reset by peer)]
gl has joined #ocaml
MegaWatS has quit ["Actually, people sometimes talk about man's "bestial" cruelty, but that is being terribly unjust and offensive to the beasts:]
MegaWatS has joined #ocaml
mattam_ has joined #ocaml
lament has joined #ocaml
lament has quit [Read error: 104 (Connection reset by peer)]
mattam has quit [Read error: 110 (Connection timed out)]
docelic has joined #ocaml
lament has joined #ocaml
graydon has joined #ocaml
<jankr>
6
ElCritter has joined #ocaml
<ElCritter>
hi
<ElCritter>
can you help me with a question?
<whee>
ELCritter: what's the question?
docelic has quit ["Client Exiting"]
lament has quit [Remote closed the connection]
<ElCritter>
whee: sorry... it's everything ok now... but i'll be back with a lot of questions for sure :-)
<ElCritter>
whee: thanks
nkoza has joined #ocaml
lament has joined #ocaml
docelic has joined #ocaml
docelic has quit ["Client Exiting"]
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
jao has joined #ocaml
docelic has joined #ocaml
pphisch has joined #ocaml
pphisch has quit ["Client Exiting"]
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
docelic has quit ["Client Exiting"]
ElCritter has quit [Remote closed the connection]
malc has joined #ocaml
gl has quit [Read error: 60 (Operation timed out)]
mellum has quit [Read error: 110 (Connection timed out)]
mellum has joined #ocaml
inapt has joined #ocaml
inapt has left #ocaml []
asqui has joined #ocaml
<asqui>
mmmkay
<asqui>
Is anyone alive?
<whee>
perhaps
malc has quit [Read error: 110 (Connection timed out)]
<asqui>
Excellent...
<SoreEel>
I twitch occasionally.
<asqui>
Okay, 2d route finding problem. Want routes from (x,y) to (u,v), take |x-u| and |y-v| and supply them to a recursive function which returns 1 if any input is 0 else returns self(x-1, y) + self(x,y-1)
<asqui>
Make sense?
<asqui>
wait a second... wait a second.....
<asqui>
SON OF A FATHER
docelic has joined #ocaml
<asqui>
sorry about that, spack attack over, problem solved. Me am idiot. Thank you for your attention.
<whee>
That'll be $500.
<whee>
:)
<asqui>
Why is it that only when i finally find someone who will listen and start to explain I manage to realise the trivial error of my code.
<asqui>
My brain hates me, it *wants* me to embarrass myself.
<nkoza>
asqui: kill it with beer
<asqui>
Now theres an idea.
<asqui>
Wait, so if you have a function "let somefun a b c = a * b * c;;
<asqui>
"
<asqui>
then that function has the type int -> int -> int -> int right?
<asqui>
why then does 'somefun 10' have the type int -> int -> int?
<asqui>
Because itll take 2 more ints then return an int?
docelic has quit ["Client Exiting"]
<whee>
yes, that's why
<whee>
somefun 10 will return a function that takes two integers
<asqui>
I dont suppose you'd like to proof read my assignment for me? (pretty please?)
<whee>
heh if you want
<asqui>
Its not quite done yet but Ill send what I have so far. What format do you prefer?
<whee>
anything will do
<asqui>
pdf? LaTeX source?
<whee>
either :D
docelic has joined #ocaml
<asqui>
whee: DCC good for you?
Yurik has joined #ocaml
<Yurik>
re
<asqui>
Yurik: Would you like to read my functional programming assignment? :)
<whee>
I'm supposed to be reading miltonroutes right :)
<asqui>
one is the queestion, the other is the answer :)
<Yurik>
asqui: yes?
<whee>
typo on page 7, missing the first h in whether :)
<asqui>
Shit, this thing is over 3000 words now
<asqui>
You read 7 pages that quick?
<asqui>
wow!
<whee>
did a quick skim first
<whee>
heh
gl has joined #ocaml
<asqui>
Well spotted.
<asqui>
I think ive gone a little over the top, considering that most people dont have a clue. Though theres no word limit, so I guess theyll just have to live with it.
<whee>
you might want to write your code a little differently as well, instead of something like 'abs(x + y)' do 'abs (x + y)'
<asqui>
I just hope he gets extra impressed by the fact that it was written in LaTeX
<whee>
just so it's consistent
<asqui>
I dont follow,
<whee>
otherwise you have a space for multiple argument calls and no space for single argument calls
<whee>
see the definition of distance for example
<whee>
'abs(x-u)' is really 'abs (x-u)', the abs function given a single argument
<asqui>
oh right, space between function and parameter.
<whee>
I'd put the space there just so there's no confusion
<asqui>
Heh yeah, the influence of imperative programming.
<asqui>
Okay.
j_bravo has joined #ocaml
<asqui>
Is all the mathematical stuff reasonably okay, caue im kind of winging it there.
<asqui>
What about cartesian products, (a,b) or (a, b)?