dylan changed the topic of #ocaml to: OCaml 3.09.1 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
kryptt has joined #ocaml
mikeX has quit ["zzz"]
gim_ has quit []
stockholm_ has joined #ocaml
<stockholm_> Hello, I'm looking for someone to give me a hand with alpha transparency in lablgtk. Thanks in advance.
ski has quit [Read error: 110 (Connection timed out)]
ski has joined #ocaml
cmeme has quit [Connection timed out]
stockholm_ has quit ["Leaving"]
cmeme has joined #ocaml
cmeme has quit [Connection reset by peer]
cmeme has joined #ocaml
cmeme has quit [Connection timed out]
cmeme has joined #ocaml
tktktk has joined #ocaml
kryptt has quit [Read error: 110 (Connection timed out)]
bluestorm has joined #ocaml
Snark has joined #ocaml
stockholm_ has joined #ocaml
dark_light has joined #ocaml
stockholm_ has quit ["Leaving"]
mrsolo_ has quit [Read error: 104 (Connection reset by peer)]
mrsolo_ has joined #ocaml
dark_light has quit [Read error: 113 (No route to host)]
SnarkBoojum has joined #ocaml
Snark has quit [Read error: 110 (Connection timed out)]
SnarkBoojum is now known as Snark
_JusSx_ has joined #ocaml
<_JusSx_> wow today today we are many
Skal has joined #ocaml
jo_l_apache has joined #ocaml
piggy_ has joined #ocaml
piggy_ has left #ocaml []
jo_l_apache has quit ["leaving"]
Anarchos has joined #ocaml
Anarchos has quit ["Vision[0.8.5-0418]: i've been blurred!"]
pauld has joined #ocaml
pauld has quit [Client Quit]
pauld has joined #ocaml
<pauld> hello! i'm learning ocaml and bumped my head
<pauld> I need some help with unions
<pango> you mean sum types probably
<pauld> probably... i'm trying to parse this kind of structure:
<pauld> type fs = File of string | Directory of fs list;;
<pauld> creating a fs:
<pauld> let newfs = Directory (File "1"::File "2"::
<pauld> Directory (File "3"::
<pauld> Directory(File "3"::File "4"::[])::[]
<pauld> )::[]
<pauld> );;
<pauld> then I have no clue on how to step through this structure
<pango> with a recursive function
<zmdkrbou> match myfs with File(s) -> bla | Directory(l) -> bli
<zmdkrbou> with bli recusively calling the function
<pauld> yes i tried with something like:
<pauld> let rec print_fs fs =
<pauld> match fs with
<pauld> [] -> []
<pauld> | File path -> print_endline path
<pauld> | Directory fs -> print_fs fs;;
<pango> in your last line, 'fs' is a fs list, not a fs
<zmdkrbou> List.map print_fs fs
<pango> and the different branches of your match don't have the same type ('a list once, then unit twice)
<pauld> ok, so I skip the first match and then all is ()?
<pango> not to mention [] is not of type fs
<pango> so that case don't exist
<pango> # let rec print_fs fs =
<pango> match fs with
<pango> | File path -> print_endline path
<pango> | Directory fsl -> List.iter print_fs fsl ;;
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?
vodka-goo has joined #ocaml
<tspier2> bluestorm?
<pango> better = than == to compare integers
<pauld> I'm trying parse a directory recursivly. The code is on http://www.pastebin.be/524/
<pango> for convenience ocaml interprets == as = for unboxed values... but semantically it's still wrong
<tspier2> Okay. How should I use the while true do statement though?
<pauld> on line 12 i want to add the enclosing directory of the file. ex /home/foo/file.txt -> foo
vodka-goo is now known as love-goo
<pauld> Could I do this in a different way?
<dylan> I thought == was for unboxed things.
<pango> == is physical equality
<dylan> Right.
<dylan> and = is structural equality
<pango> # let a = 1.0 and b = 1.0 in a == b ;;
<pango> - : bool = false
<dylan> where as let a = 1.0;; let b = a;; a == b is true
<pango> correct
<dylan> floats are boxed, yes?
<pango> yes, most of the time
<dylan> (right, float array being special)
<pango> and record with only floats
<dylan> ocaml's internals are fun.
<ita> fun like in function
<dylan> ocaml puts the fun in function.
<dylan> and haskell puts the backslash in function. :)
Snark has quit ["Leaving"]
<pango> tspier2: personally I'd go for a recursive function
<pango> # let rec loop () =
<pango> print_string "Hello! ";
<pango> loop () ;;
<tspier2> Oh. I get it. So after else, I would just put loop ();; and then it would look for let rec loop () which would be defined at the top?
<pango> yes, the "loop" function would call itself
<tspier2> Okay.
love-goo has quit ["Connection reset by by pear"]
ramkrsna has quit [Connection timed out]
ramkrsna has joined #ocaml
<pauld> if i'm going to learn ocaml should i learn the revised syntax?
mikeX has quit ["later"]
<Smerdyakov> Probably not
<pango> I know few programs that use the revised syntax
<dylan> the revised syntax is enjoyed by non-ocaml programmers and few else.
<tspier2> pagno, so this would work: http://pastebin.be/526/
<tspier2> Ah
<tspier2> pango*
<pango> no
<pango> as is, loop function stops line 5
<tspier2> Ah, what should I change?
<tspier2> pango, can you help me please?
<pauld> tspier, what do you want to do?
<tspier2> I want the expression to be evaluated forever, so it would keep printing "The value of a is not the same as the value of b."
<ita> pauld: you need not
<tspier2> Thanks, pango.
<pauld> pango, why do you need ()?
<pango> pauld: where ?
<ita> tspier2: while true do print_newline(); done ?
<pauld> pango, as argument to loop
<pango> pauld: arguments is what differenciates functions from values, afaik
<pango> that's the difference between let a = 1 and let a () = 1 at least ;)
ramkrsna has quit [Connection timed out]
<pauld> ok
<pauld> ... trying it out
<pango> let a () = 1 is a shortcut for let a = (fun () -> 1)
<pauld> ahh right, forgot that
<tspier2> pango, I think I need another semicolon in the first link you gave me, because it won't run.
ramkrsna has joined #ocaml
<pango> tspier2: first version defines the function loop, but doesn't call it
<pango> tspier2: you still need a loop ()
<pango> tspier2: but what about reading some more about ocaml ? you won't go very far without functions
<tspier2> Okay
<tspier2> Okay. Thanks.
Anarchos has joined #ocaml
Skal has quit [Remote closed the connection]
_JusSx_ has quit ["leaving"]
slipstream has joined #ocaml
pauld has quit [Read error: 110 (Connection timed out)]
pauld has joined #ocaml
ramkrsna has quit [Connection timed out]
slipstream-- has quit [Connection timed out]