det has quit [Read error: 110 (Connection timed out)]
<pauld>
oh. thanks! It's going to take some time to grock this.
<pauld>
List.iter returns ()?
<pango>
yes
mikeX has joined #ocaml
<pauld>
thanks for your time
<pango>
np
kryptt has joined #ocaml
Schmurtz has quit [Read error: 110 (Connection timed out)]
<_JusSx_>
use pastebin
mikeX has quit ["leaving"]
kryptt has quit [Remote closed the connection]
pango is now known as pangoafk
pangoafk is now known as pango
Skal has quit [Remote closed the connection]
jo_l_apache has joined #ocaml
pauld has quit [Read error: 110 (Connection timed out)]
mikeX has joined #ocaml
tspier2 has joined #ocaml
<tspier2>
Let's say I defined two values. I'll call them a and b. I also created another one called c. Let's say c is the value of a - b. If I typed "print_endline c;;", would it print out the value of a-b?
<bluestorm>
no
<bluestorm>
print_endline : string -> unit
<bluestorm>
c : int
<bluestorm>
problem :p
<Ainulindale>
(print_int ;-) )
<bluestorm>
print_endline (string_of_int c);
<bluestorm>
hum print_int doesn't add \n
<Ainulindale>
Who cares ? :>
<bluestorm>
Printf.printf "%d\n" c; could be used too
<tspier2>
So, print_int c;; would work?
<bluestorm>
yes
<bluestorm>
(a and b have to be int, too)
<tspier2>
let a = 5;
<tspier2>
let b = 1;
<tspier2>
let c = a - b;
<tspier2>
<tspier2>
print_int c;;
<tspier2>
So would that work then?
<bluestorm>
no
<bluestorm>
let a = 5 in
<bluestorm>
or
<tspier2>
:/
<bluestorm>
let a = 5;;
<tspier2>
Oh
<bluestorm>
(same for the others)
<tspier2>
So I should just end variables that contain an integer value with two semicolons?
<bluestorm>
hum
<bluestorm>
this will declare global values
<bluestorm>
but if you only want local variables
<bluestorm>
use let a = 2 in
<tspier2>
Okay. Thanks.
<bluestorm>
(let <var> = <val> in <block> is the general syntax)
jo_l_apache has quit ["leaving"]
malc__ has joined #ocaml
malc__ has left #ocaml []
<tspier2>
bluestorm, how would I get input from the user? I know in Python an example would be, int(raw_input("Enter your input:"))
<bluestorm>
hum
<bluestorm>
read_int()
<bluestorm>
read_line()
<tspier2>
How do I put whatever text the user will see though?
<bluestorm>
print_string
<bluestorm>
print_endline
<bluestorm>
(and print_int print_char)
<bluestorm>
hum
<tspier2>
Oh...so, I would do this:
<bluestorm>
you may need some manual, don't you ?
<tspier2>
print_endline "Enter your input:"
<tspier2>
read_line()
<bluestorm>
hum
<tspier2>
The manual was killing me, so I found an actual tutorial.
<bluestorm>
print_endline "Enter your input:"
<bluestorm>
let input = read_line() in
<bluestorm>
hum
<tspier2>
Oh, okay.
<bluestorm>
i forgot the ; after print_endline ""
ita has joined #ocaml
<tspier2>
Hmm, didn't work.
<tspier2>
Alright. I need some time to mess with this. I'll be back later.
tspier2 has left #ocaml []
pauld has joined #ocaml
pauld has quit [Client Quit]
smimou has joined #ocaml
bluestorm has quit [Remote closed the connection]
smimou has quit [Remote closed the connection]
smimou has joined #ocaml
bluestorm has joined #ocaml
tspier2|Ausen has joined #ocaml
<tspier2|Ausen>
Alright, I'm up to if/else statements with defined variables. Let me show you my source, and then if one of you can help me put it into a continous loop to evaluate it, that would be great.
<tspier2|Ausen>
let x = 5 in
<tspier2|Ausen>
let y = 1 in
<tspier2|Ausen>
if x == y then
<tspier2|Ausen>
print_string "X is the same value as Y."
<tspier2|Ausen>
else
<tspier2|Ausen>
print_string "X is not the same value as Y.";;
tspier2|Ausen is now known as tspier2
Skal has joined #ocaml
<bluestorm>
tspier2,
<bluestorm>
what do you want to loop ?
<tspier2>
I want it to continue evaluating whether x == y or not, and then printing the message.
<Ainulindale>
To do what ? You won't change the values...
<tspier2>
I know.
<Ainulindale>
tspier2: declare a recursive function (let rec)
<Ainulindale>
if you like it =)
<Ainulindale>
but you'll make the stack explode
<tspier2>
So would I just put, "let rec()" before the if/else statement?
<bluestorm>
hum
<bluestorm>
while true do ... would be ok too
<bluestorm>
while true do
<bluestorm>
...
<bluestorm>
done;
<Ainulindale>
Yuk ;-)
ulfdoz has quit [niven.freenode.net irc.freenode.net]
_JusSx_ has quit [niven.freenode.net irc.freenode.net]
pango has quit [niven.freenode.net irc.freenode.net]
_JusSx_ has joined #ocaml
pango has joined #ocaml
ulfdoz has joined #ocaml
bluestorm has quit ["Leaving"]
pauld has joined #ocaml
<tspier2>
So, would I put while true do above the if and else statement, or above the print_string statements?