<whee>
the depth at any node is simply the higher depth of its two children, plus one
* RichiH
doesn't understand that one
<RichiH>
"higher depth"?
<RichiH>
node -> node -> node -> atom == depth of 4
<whee>
larger, longer, whatever
<whee>
erm wait I think I confused myself on your data type
<whee>
heh
<RichiH>
it's basically a tree
<RichiH>
nothing else
<whee>
okay
<RichiH>
either, i got two branches going further down or i got an Atom, meaning some kind of data
<whee>
well if you have a node in a tree (let's assume this node is the root), the depth of the tree starting from that node is the depth of the children
<whee>
the higher depth of all the trees starting from that first node
<whee>
I think this works :|
* whee
draws pictures
* RichiH
isn't entirely sure we are talking about the same type of data structure
<whee>
just a binary tree, right?
<RichiH>
a binary tree can have data in it's nodes, too. but apart from that, yes
<whee>
this might be off by one somewhere but it looks good to me
<RichiH>
i can't put it into code, though
<RichiH>
# let rec isBalanced arg = match arg with
<RichiH>
that will only say it's balanced when x equals y
<whee>
looks like it works, also looks a little wasteful
<RichiH>
wouldn't be |x-y|<=1 better?
<whee>
looking at the one I just pasted?
<whee>
if the trees have the same depth, it may or may not be balanced, so we check the subtrees
<whee>
it's only not balanced if the depth of one side is unequal to the depth of the other
<RichiH>
yes
<RichiH>
but as i said ealier, a difference of one will still be balanced
<whee>
really? hrmf
<whee>
yep
<whee>
heh
<RichiH>
so is |x-y|<=1 the right thoing to do?
* RichiH
can't type any more
<whee>
that's the easy way to fix it
<whee>
heh
<whee>
attempting to find existing code that does this
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
<RichiH>
whee: so, you got any further leads?
<whee>
for?
mattam has quit ["-all "May the source be with you""]
<RichiH>
heh
<RichiH>
guess ;)
<whee>
jej
<RichiH>
my damn balance
<whee>
I can't find any examples
* RichiH
couldn't, either
<whee>
which is odd
<whee>
it seems that most algorithms just make sure the thing's balanced when it inserts
MegaWatS has quit ["Oceania has ALWAYS been at war with Eastasia!"]
<RichiH>
ok, i am done for today...
<RichiH>
i just can't get it to work
<RichiH>
i need to sit down and do hours and hours and hours of ocaml tutorials
<RichiH>
but not today
<RichiH>
that's reserved for the weekend
<RichiH>
whee: thanks again and cu
RichiH has quit ["/sleep"]
Yurik has joined #ocaml
<Yurik>
re
Yurik has quit [Client Quit]
whee has quit ["ircII EPIC4-1.1.7 -- Are we there yet?"]
nkoza has quit [Remote closed the connection]
mrvn has joined #ocaml
mrvn_ has quit [Read error: 60 (Operation timed out)]
mrvn_ has joined #ocaml
mrvn_ has quit [Client Quit]
mrvn has quit [Read error: 110 (Connection timed out)]
mrvn has joined #ocaml
yangsx has joined #ocaml
yangsx has quit [Remote closed the connection]
_bejito_ has quit [Read error: 104 (Connection reset by peer)]
BeJiTo has joined #ocaml
mattam has joined #ocaml
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
flar_ has quit ["leaving"]
Yurik has joined #ocaml
<Yurik>
re
karryall has joined #ocaml
malc has joined #ocaml
Yurik has quit [Read error: 54 (Connection reset by peer)]
ayrnieu has joined #ocaml
malc has quit [Read error: 110 (Connection timed out)]
karryall has quit [Remote closed the connection]
nerdlor has joined #ocaml
MegaWatS has joined #ocaml
malc has joined #ocaml
nkoza has joined #ocaml
karryall has joined #ocaml
malc has quit [Read error: 110 (Connection timed out)]
RichiH has joined #ocaml
nerdlor has quit [Remote closed the connection]
gl has quit [Read error: 54 (Connection reset by peer)]
gl has joined #ocaml
kENpEX has joined #ocaml
<kENpEX>
hi All!!!
RichiH has quit [Remote closed the connection]
<kENpEX>
??? all dead?
<MegaWatS>
yes, we`re all dead, decomposing corpses with our pale, white heads lying in our keyboards and flys circling us ;|
graydon has joined #ocaml
Yurik has joined #ocaml
<Yurik>
re
<Yurik>
nobody had started Generic Security Service (GSS) API for OCaml? :-)
Yurik has quit [Remote closed the connection]
Yurik has joined #ocaml
<Yurik>
re
<Yurik>
damn, got disconnected
<Yurik>
so, nobody did GSS API for caml? :-)
Yurik_ has joined #ocaml
Yurik has quit [Read error: 54 (Connection reset by peer)]
<Yurik_>
re
Yurik_ is now known as Yurik
<kENpEX>
I'm a beginner (and begginer) in the world of FP...
Yurik has quit [Read error: 54 (Connection reset by peer)]
<kENpEX>
I'm searching for a good FL to learn... :) I'm still undecided which is the best to start with
<kENpEX>
I've seen so far: Ml, Mercury, Haskell, OCaml, Erlang
<kENpEX>
can anyone here help me?
<MegaWatS>
depends
<MegaWatS>
on what you want to do with it
<MegaWatS>
ie why you want to learn it
<kENpEX>
mhm just for fun???
<kENpEX>
I started with haskell... I like it but it has some strange syntax in some places imho
<MegaWatS>
well the languages, and the learning experience they give, would have different advantages
<kENpEX>
I like much ML it's neat... but it doesn't have OO (afaik) and I don't like it's type definition system
<MegaWatS>
for the pure learning experience of the functional, mathematical paradigm - scheme or, when you want something statically-typed, haskell would be best
<kENpEX>
Erlang seems good too... and it seems to be used in real projects
<kENpEX>
no I don't want anything that's lisp/scheme like
<MegaWatS>
if you want something practical, either erlang or ocaml would be best imho - ocaml even more, as it has oop
<MegaWatS>
and ( relatively ) lots of libraries
<ayrnieu>
kenpex - Erlang is lisp/scheme like, in many ways if not in syntax.
<kENpEX>
and I want to learn something that could be usefull too... Haskell is good but it isn't used much in real-world apps
<kENpEX>
mhm
<MegaWatS>
as I said
<kENpEX>
is OcaML - ML compatible???
<MegaWatS>
i would recommend ocaml for that
<MegaWatS>
no its not compatible to standard ml
<MegaWatS>
but very similar
<ayrnieu>
kenpex - if you mean 'Standard ML', of course not. This is a FAQ.
<MegaWatS>
I have to admit though, I don`t know much about mercury, so I can`t say much about it
<kENpEX>
mhm is there a doc that explains the differences between OcaML and SML? I already know SML (a bit) this would save me some time
<kENpEX>
:)
<MegaWatS>
hmm
<ayrnieu>
O'Caml and Erlang and Haskell and Mercury and SML are good for real-world apps, and any of them would be a fine place to start (I have a slight preference for Erlang, but you needn't).
<kENpEX>
Mercury seems to be good, but I don't like its syntax it seems to be confusing to me
<MegaWatS>
well you could just start reading the ocaml docs at the ocaml hp
<MegaWatS>
otherwise, I don`t know
<kENpEX>
ayrnieu: O'Caml and SML seems to have the faster compilers btw...
<MegaWatS>
sml is nice too, but it lacks oop support
<kENpEX>
the only thing that I really don't like about O'Caml
<MegaWatS>
persnally, I think sml is quite a bit 'cleaner' in many regards, but also quite lacking
<kENpEX>
is that it seems too much "imperative" to me...
<ayrnieu>
kenpex - O'Caml and Erlang (I'm not familiar with SML compilers) both have very fast compilers. Haskell and Mercury both have much slower compilers.
<MegaWatS>
you can do very functional coding in ocaml
<kENpEX>
many examples are imperative, many sources are done using imperative stuff
<MegaWatS>
some things are just easier to do in an imperative matter
<MegaWatS>
and the ocaml attitude to things is to use the right method for each problem
<ayrnieu>
kenpex - read the O'Caml ORA book (online at www.ocaml.org). This should give you a better idea of how 'imperative' O'Caml is and isn't.
<MegaWatS>
ie where imperative is better / more natural, use that, where functional is cleaner use that etc
<kENpEX>
ayrnieu: I'll try it
<kENpEX>
yes I know that imperative can be good
<kENpEX>
ML itself supports imperative stuff
<MegaWatS>
but you can also write (almost) purely functional programs in ocaml, too
<kENpEX>
but it seems that it doesn't promote this stuff so much as O'Caml
<kENpEX>
or mabye it's only that the ML tutorials that I found are 100% FP, while most O'Caml tutorials are mixed
<MegaWatS>
but if you want that, I think maybe haskell (or clean) would be the better place to start
<kENpEX>
MegaWatS: Is haskell "more functional" than ML??? I think that U can translate Haskell->ML quite easily
<ayrnieu>
(kenpex - from your position of ignorance, the best direction to move in is *anywhere else*.)
<MegaWatS>
they also have much more efficient, terse syntax (especially tailored towards it) for purely functional programming
<ayrnieu>
kenpex - Haskell is purely functional.
<MegaWatS>
haskell is PURELY functional - you can`t have any sideeffects
<MegaWatS>
ie it is lazy
<ayrnieu>
megawats - well, you can in a way; Haskell programs modify the state of the universe in-place =)
<kENpEX>
yep I know that haskell is purely functional, but it seems to me that the functional part of ML is much like haskell
<MegaWatS>
of course
<kENpEX>
I need a good FP tutorial for O'Caml to make my mind :)))
<ayrnieu>
Erlang is the most dynamic of all the languages under discussion -- but if your distate for Lisp goes deeper than syntax, you may not appreciate that.
<MegaWatS>
but haskell`s (admittedly, very unusual and requiring of shedding old habits) very terse syntax, and pureity make it more tailored towards pure fp
<ayrnieu>
kenpex - get the ORA book off www.ocaml.org
<MegaWatS>
ie, things like list comprehension
<kENpEX>
ayrnieu: no I only dislike lisp syntax... :)
<kENpEX>
ayrnieu: I'm going to get it
<MegaWatS>
kENpEX, you know lisp's syntax is there for a deeper reason, dont you?
<ayrnieu>
mega - it's a bit silly to say that Haskell's syntax requires "shedding old habits". What habits do you mean?
<MegaWatS>
"and pureity"
<MegaWatS>
also
<ayrnieu>
mega - err, I take that back. I won't say that saying that is silly until I know what you mean =)
<MegaWatS>
it is dependant on indendation
<ayrnieu>
megawats - no it isn't.
<MegaWatS>
which is very unfamiliar looking to many people
<kENpEX>
ayrnieu: can't find that book in the "books" section...
<MegaWatS>
well, you CAN use haskell in non-indendation dependand mode, but that is not the usually preferred method
<ayrnieu>
megawats - hm, OK. The idiom is to use Haskell's 'offside rule' which allows you to use indentation instead of braces and the like, and I suppose that this may be momentarily confusing.
<ayrnieu>
kenpex - it's there.
<MegaWatS>
well I just think, haskell looks very strange and unfamiliar to the unschooled eye
<MegaWatS>
it takes a while getting used to for people coming from C / C++ / pascal / ...
<ayrnieu>
mega - all languages look strange and unfamiliar to the unschooled eye; this is why you school your eyes.
<kENpEX>
ayrnieu: U mean the oreilly's book???
<MegaWatS>
kENpEX: yes
<ayrnieu>
mega - but yes, I suppose that the majority of programmers come from C and similarly syntaxed languages.
<MegaWatS>
ayrnieu: whereas languages like ml, I think, will offer more things someone like that can find familiar
<ayrnieu>
kenpex - there's a link on the right side (under the Documentation section) named "O'Rielly book". http://caml.inria.fr/oreilly-book/
<MegaWatS>
I mean differences like between sometzhing [ excuse if this is not exactly valid haskell syntax, it`s been a while ] [ x | x <- y : x > 2 ] versus List.filter (( <= ) 2) y
<ayrnieu>
You probably mean [x | x <- y, x > y], but OK.
<kENpEX>
ayrnieu: kk found... I didn't understand what U meant with "ORA"
<ayrnieu>
kenpex - oh, sorry.
<MegaWatS>
the former will just look like line noise to someone who doesn`t know what it`s supposed to mean, whereas he can make a guess about the latter
<MegaWatS>
ayrnieu: yes. as I said, it`s been quite a while since I last used haskell :)
<ayrnieu>
mega - these are, nonetheless, poor reasons for someone admittedly interested in learning a language to avoid Haskell =)
<MegaWatS>
I did not offer them as reasons why haskell is bad
<MegaWatS>
I just said that, if he finds haskell syntax too unfamiliar for his tastes, that maybe ml`s will be more familiar
<kENpEX>
many FP languages tend to be very terse... terse is good but some languages are just weird... I like haskell and ML because their syntax is familiar, math-like
<MegaWatS>
heh :)
<ayrnieu>
mega - OK. My position, by contrast, is that unfamiliarity is nearly an advantage =)
<kENpEX>
and I find ML better than Haskell when it comes to the syntax
<MegaWatS>
ayrnieu, actually, I agree
<kENpEX>
kk now I'll read that book
<MegaWatS>
I just offered that expanding on a question / comment that was already there
<ayrnieu>
kenpex - have fun.\
<kENpEX>
if O'Caml is something like an "expanded" ML then it will be surely my choice
<kENpEX>
10x
<ayrnieu>
ah, OK.
<kENpEX>
ah the last thing
<kENpEX>
are there many compilers for O'Caml???
<MegaWatS>
I`m not one to evangelize - if someone says he doesnt want to try language "X" because of synax, I`m not going to say "that is a bad reason" but "well, maybe language Y, which is still similar in other respects, might be more to your tastes"
<kENpEX>
I'm expecially interested into O'Caml->java bytecode or -> c ones
<MegaWatS>
as far as I know there is only the one made by inria
<kENpEX>
also does O'Caml support parallel stuff??? (multithreading etc...)
<MegaWatS>
yep
<ayrnieu>
kenpex - you probably only think that you're interested in the latter. O'Caml can compile to native code, to bytecode, or O'Caml can compile-on-the-fly (like Perl and Python and such).
<kENpEX>
ayrnieu: to its own bytecode U mean???
<MegaWatS>
yes
<ayrnieu>
kenpex - be careful, though: parallelism is not concurrency.
<ayrnieu>
kenpex - most byte compilers compile to their own bytecode :-/
<kENpEX>
ayrnieu: yep I know, but as I talked about java bytecode eralier there could be some confusion
<ayrnieu>
kenpex - I don't know of an O'Caml compiler that produces JVM bytecode though, sorry.
* ayrnieu
nods.
<kENpEX>
ayrnieu: there are many FP languages that compile -> java bytecode too
<kENpEX>
ok
<ayrnieu>
kenpex - OK.
owll has joined #ocaml
<kENpEX>
mhm
<kENpEX>
mhhhm
<kENpEX>
what's the difference between let sum a b=a+b and let sum = function a -> function b -> a+b in O'Caml??? Can't understand it
<ayrnieu>
kenpex - there's no difference.
<kENpEX>
ayrnieu: ok, fine :)
<kENpEX>
ayrnieu: do U belive that the O'Caml compiler can generate better code (==faster) than MLton with a pure-functional input???
<kENpEX>
I've seen some benchmarks of O'Caml between Erlang, ML or Haskell... but they always used imperative programming for O'Caml
<ayrnieu>
kenpex - I've not been interested enough in SML to care about its performance, sorry. I haven't heard anything about MLton's comparative runtime efficiency.
<kENpEX>
mhm
<ayrnieu>
kenpex - that's probably because the O'Caml was optimized for the task, and because the task was created in the context of imperative programming languages.
<MegaWatS>
if I am thinking about the right compiler right nw, wasnt mlton that one that created incredibly efficient code, btu wasn`t quite standards compliant because it evaluated curried function applications in the wrong order?
<MegaWatS>
or am I thinking about the wrong one?
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
owll has quit ["Client Exiting"]
karryall has quit []
<kENpEX>
dunno
<kENpEX>
MegaWatS: MLton is really fast, is the most optimizing ML compiler around... but I don't know of this bug
<kENpEX>
I'm learning O'Caml... :) It seems that the functional part of the language is very close to ML... that's fine
<kENpEX>
I wonder why they changed some little details... like anonymous function syntax, function declaration and stuff like that
<MegaWatS>
they didnt "change" it
<MegaWatS>
standard ml wasn`t around yet when ocaml was ivnented
<kENpEX>
I see
<kENpEX>
mhm, but the home says that OCamls descends from ML
<ayrnieu>
kenpex - yes. You are very consistent in your mis-use of ML to mean SML.
<kENpEX>
:)
<kENpEX>
well I know SML... what is ML???
<ayrnieu>
What SML standardized, and what O'Caml is based on =)
<MegaWatS>
also, ml is these days usually used to refer to the whole family of languages mostly, including sml and ocaml
<ayrnieu>
what both of them derive from, I should say.
<ayrnieu>
kenpex - ML was originally a theorem-proving language, I think.
Dalroth has joined #ocaml
Yurik has joined #ocaml
<Yurik>
re
Yurik_ has joined #ocaml
<Yurik_>
re
Yurik has quit [Read error: 104 (Connection reset by peer)]
Torquemada has joined #ocaml
zack has joined #ocaml
Yurik_ has quit [Read error: 104 (Connection reset by peer)]
AndyA has joined #ocaml
ayrnieu has quit ["ERC v2.93 $Revision: 1.308 $ (IRC client for Emacs)"]
zack has left #ocaml []
malc has joined #ocaml
gl has quit [Connection timed out]
malc has quit [Read error: 110 (Connection timed out)]
gl has joined #ocaml
BeJiTo has quit [Read error: 104 (Connection reset by peer)]