<araujo>
Aradorn: got time to answer a question? :-)
<Aradorn>
heh if i knew anything about ocaml mayb e=p
<Aradorn>
i actually just started learning it a few days ago =p
<araujo>
hah, ok
<araujo>
well, for anyone here, how do i use streams in the repl?
<Aradorn>
whats repl? =p
<Aradorn>
im going to atleast learn something from your question heheh
<araujo>
read-eval-print-lop
<araujo>
read-eval-print-loop
<Aradorn>
ahhh
<araujo>
hah :-)
<Aradorn>
stupid acronyms =p
<araujo>
haha.. really, you guys don't know it?
* araujo
is used to it from Lisp
<Aradorn>
this is my first functional language so its taking me a bit to get used to. which is why i feel like such a newb lol
<araujo>
That's good.
<araujo>
im also sort of new to ocaml
<araujo>
though not to functional languages.
<Aradorn>
heh thats my problem
<Aradorn>
functional programming is sooooo different to me
<Aradorn>
its taking me a bit to wrap my brain around the concepts
<araujo>
what languages do you program at?
<Aradorn>
Java mostly
<araujo>
oh i see
<Aradorn>
i know a little C and C++
<araujo>
well yes, it might be quite a different :-)
<Aradorn>
=)
<Aradorn>
im developing a search engine atm and one of my partners showed me ocaml and persuaded me to learn it
<araujo>
Though Ocaml also implement imperative programming, i suppose that eases the learning process
<Aradorn>
so we are now in the processes of rewriting our system from java to ocaml because of how much better functional languages are than imperative ones. and since ocaml can be compiled to native code its ALOT faster (natrually) than the java VM
<Aradorn>
yeah
<araujo>
Yeah, indeed
<araujo>
Good to hear.
<araujo>
Good to hear that, one less java application in this world :-)
<Aradorn>
made our networking architechture MUCH easier but i still cant make heads or tails of it
<Aradorn>
haha
<Aradorn>
java is nice for what it is
<araujo>
Really never found my way around it
<Aradorn>
but im wishing my university offered 1 class in a functional language to show how powerful they are
<Aradorn>
java's advantage is the API
<araujo>
yeah, that'd be nice
<Aradorn>
makes it very easy to learn and use all the tools you have
<araujo>
really?
<Aradorn>
yeah
<araujo>
it always seemed pretty nasty to me :-/
<Aradorn>
i mean if you wanted to know ANYTHING about the Integer class you can just goto the API and see all the methods, their parameters, their return types and what they do by the descriptions
<araujo>
mm... well that isn't something that new
<araujo>
i could do the same with smalltalk for example
<Aradorn>
right but alot of langauges dont take advantage of it
<Aradorn>
one thing i dont understand about ocaml is why modules like String arnt opened automatically like the pervasives module is
<araujo>
Don't look at me , im also newb :-)
<Aradorn>
Syntax that is added just for the sake of convenience, and not for any technical reasons, is called syntactic sugar. In OCaml, operators can be "de-sugared" by enclosing them in parentheses,
<Aradorn>
rofl
<Smerdyakov>
Aradorn, why would you want those modules opened automatically? The module name is part of the unique identifier for each of its contents.
<Smerdyakov>
Aradorn, it's not like in C where you have libraryName_subLibraryName_function as an identifier within a .a file.
<Aradorn>
i guess its just my imperative experience
<Smerdyakov>
This is a completely orthogonal issue.
<Smerdyakov>
It's your _C_ experience.
<Aradorn>
java =P
<Smerdyakov>
Java has the same thing.
<Smerdyakov>
The methods in the String class aren't accessed just as the methods in the current class.
<Aradorn>
in java i dont have to import the String class in order to use substring
<Smerdyakov>
And, in OCaml, you don't have to "import" anything to use the String module.
<Aradorn>
i can just call String j; j.substring(4);
<Aradorn>
right but I still eithe rhave to say open String or call String.set or String.whatever
<Aradorn>
instead of the string itself on those function
<Aradorn>
its just a different style
<Smerdyakov>
And you had to type String in your Java example above, also....
<Aradorn>
to declare a strin gyes
<Smerdyakov>
You never need that sort of declaration in OCaml.
<Smerdyakov>
It evens out to a better mix, I'd say.
<Aradorn>
right because its functional there is no assignment
<Smerdyakov>
No; because ML has type inference.
<Aradorn>
ok i dont understand something
<Aradorn>
if i do let rec length = function
<Aradorn>
[] -> 0
<Aradorn>
| (x::xs) -> 1 + length xs;;
<Aradorn>
why do i cons x with a list?
<Aradorn>
x::xs what does this do? (i thought i added the element x to the list xs)
<Smerdyakov>
Are you reading through a tutorial or just looking at random code?
shammah has quit ["Leaving"]
<Aradorn>
reading a tut
<Aradorn>
dosnt actually explain why it took out the match case and put in function instead
<Aradorn>
just says you cant
<Aradorn>
er can
<Aradorn>
and the list question is a byproduct =p
<Smerdyakov>
Look for discussion on "pattern matching."
<Aradorn>
thats what im reading
<Smerdyakov>
Then it should explain exactly what this all means.
<Aradorn>
nope.. gah oh well
<Aradorn>
ill ask my friend tomorrow
<Aradorn>
do parameteres have a specific depth they can go before they need to be given again?
<Aradorn>
like if i declare a function p (x:int) = let j = 0 in let b = 2*j*x in let c x = j*x*x in (b,c)
<Aradorn>
in the function c do i need to declare that x param or is it understood from the global scope of the top function p
<mrvn>
You are declaring a new x distinct from the top level one.
<Aradorn>
ah so its scope changes
<mrvn>
let p x = let j = 0 in let b = 2*j*x in let c y = j*y*y in (b,c)
<mrvn>
That's what you wrote.
<mrvn>
You are shadowing a previous parameter.
<Aradorn>
function p (x:int) = let j = 0 in let b = 2*j*x in let c x = j*x*x in (b,c x) is what im looking at (forgot the param of c in the end)
<mrvn>
Still shadowing.
<Aradorn>
k
<Aradorn>
so its two different values used for x... right?
<mrvn>
It's two different x used with the same value.-
<Aradorn>
hrm ok...
<mrvn>
The (b, c x) assigns x to x.
<Aradorn>
gets kinda confusing =
<Aradorn>
because it evaluates the last function in the scope first?
<mrvn>
Don't shadow variables then.
<Aradorn>
im not im learning, this example does it was trying to understand it
<mrvn>
The first thing it evaluates is j, then b, then c and then the pair I believe.
<Aradorn>
k
<Aradorn>
there an easy way to do debug print lines on the top loop
_shawn has quit [Read error: 110 (Connection timed out)]
cjohnson has quit [Remote closed the connection]
ulfdoz_ has joined #ocaml
ulfdoz has quit [Read error: 145 (Connection timed out)]