flux changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 4.01.0 http://bit.ly/1851A3R | http://www.ocaml.org | Public logs at http://tunes.org/~nef/logs/ocaml/
SpindleApparatus has joined #ocaml
nikki93_ has joined #ocaml
travisbrady has joined #ocaml
shinnya has joined #ocaml
zpe has joined #ocaml
zpe has quit [Ping timeout: 252 seconds]
nikki93_ has quit [Remote host closed the connection]
ollehar has quit [Quit: ollehar]
travisbrady has quit [Quit: travisbrady]
travisbrady has joined #ocaml
manizzle has quit [Remote host closed the connection]
manizzle has joined #ocaml
zpe has joined #ocaml
Neros has quit [Ping timeout: 245 seconds]
zpe has quit [Ping timeout: 264 seconds]
talzeus has joined #ocaml
ollehar has joined #ocaml
nikki93 has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
Simn has quit [Quit: Leaving]
madroach has joined #ocaml
ollehar has quit [Ping timeout: 252 seconds]
zpe has joined #ocaml
zpe has quit [Ping timeout: 264 seconds]
travisbrady has quit [Quit: travisbrady]
csakatoku has joined #ocaml
q66 has quit [Quit: Leaving]
zpe has joined #ocaml
zpe has quit [Ping timeout: 246 seconds]
watermind has quit [Quit: Konversation terminated!]
yacks has quit [Ping timeout: 264 seconds]
csakatoku has quit [Remote host closed the connection]
zpe has joined #ocaml
csakatoku has joined #ocaml
csakatoku has quit [Ping timeout: 246 seconds]
chrisdotcode_ has joined #ocaml
chrisdotcode has quit [Ping timeout: 245 seconds]
zpe has quit [Ping timeout: 245 seconds]
f[x] has joined #ocaml
nikki93 has quit [Remote host closed the connection]
zpe has joined #ocaml
vpm has quit [Ping timeout: 245 seconds]
yacks has joined #ocaml
fryguybob has quit [Ping timeout: 252 seconds]
nikki93 has joined #ocaml
zpe has quit [Ping timeout: 264 seconds]
nikki93 has quit [Remote host closed the connection]
zpe has joined #ocaml
lusory has joined #ocaml
cdidd has quit [Ping timeout: 240 seconds]
zpe has quit [Ping timeout: 256 seconds]
yacks has quit [Quit: Leaving]
steshaw has joined #ocaml
zpe has joined #ocaml
nikki93 has joined #ocaml
zpe has quit [Ping timeout: 245 seconds]
nikki93 has quit [Ping timeout: 256 seconds]
Drup has quit [Quit: Leaving.]
gour has joined #ocaml
zpe has joined #ocaml
zpe has quit [Ping timeout: 246 seconds]
Yoric has joined #ocaml
zpe has joined #ocaml
nikki93 has joined #ocaml
nikki93 has quit [Ping timeout: 245 seconds]
Yoric has quit [Ping timeout: 260 seconds]
csakatoku has joined #ocaml
zpe has quit [Ping timeout: 240 seconds]
csakatoku has quit [Remote host closed the connection]
steshaw has quit [Ping timeout: 240 seconds]
steshaw has joined #ocaml
zpe has joined #ocaml
<adrien> morning
f[x] has quit [Remote host closed the connection]
f[x] has joined #ocaml
zpe has quit [Ping timeout: 240 seconds]
yacks has joined #ocaml
nikki93 has joined #ocaml
nikki93 has quit [Ping timeout: 252 seconds]
zpe has joined #ocaml
nikki93 has joined #ocaml
UncleVasya has joined #ocaml
zpe has quit [Ping timeout: 260 seconds]
nikki93 has quit [Remote host closed the connection]
manizzle has quit [Ping timeout: 264 seconds]
nikki93 has joined #ocaml
wwilly has joined #ocaml
zpe has joined #ocaml
f[x] has quit [Ping timeout: 260 seconds]
zpe has quit [Ping timeout: 256 seconds]
vpm has joined #ocaml
levi has quit [Read error: Connection reset by peer]
levi has joined #ocaml
zpe has joined #ocaml
ulfdoz has joined #ocaml
talzeus has quit [Remote host closed the connection]
talzeus has joined #ocaml
zpe has quit [Ping timeout: 245 seconds]
talzeus has quit [Ping timeout: 252 seconds]
nikki93 has quit [Remote host closed the connection]
Simn has joined #ocaml
nikki93 has joined #ocaml
zpe has joined #ocaml
UncleVasya has quit [Remote host closed the connection]
zpe has quit [Ping timeout: 252 seconds]
zpe has joined #ocaml
nikki93 has quit [Remote host closed the connection]
Anarchos has joined #ocaml
ggole has joined #ocaml
ollehar has joined #ocaml
Neros has joined #ocaml
mfp has joined #ocaml
zpe has quit [Remote host closed the connection]
Kakadu has joined #ocaml
q66 has joined #ocaml
serge has joined #ocaml
pango has quit [Remote host closed the connection]
csakatoku has joined #ocaml
pango has joined #ocaml
f[x] has joined #ocaml
darkf has quit [Quit: Leaving]
zpe has joined #ocaml
csakatoku has quit [Ping timeout: 252 seconds]
zpe has quit [Ping timeout: 240 seconds]
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
ulfdoz has quit [Ping timeout: 264 seconds]
ulfdoz has joined #ocaml
serge has quit [Remote host closed the connection]
SpindleApparatus has quit [Ping timeout: 264 seconds]
zpe has joined #ocaml
zpe has quit [Ping timeout: 245 seconds]
<jpdeplaix> gasche: could you handle this one ? http://caml.inria.fr/mantis/view.php?id=6184
f[x] has quit [Ping timeout: 246 seconds]
brainacid has joined #ocaml
<brainacid> Salutations from Georgia US
<brainacid> Im very new to programming
<brainacid> Using GreenTea Press How to Think Like a Computer Scientist
<brainacid> Seerking assistance with an exercise
<brainacid> Anyone awake that would like to help? Its a Chapter 3 exercise. Nothing hard but I cant seem to figure it out
<ggole> Go ahead and ask
<ggole> People may or may not answer: it is IRC, after all
<brainacid> Ok
<brainacid> let print_lyrics() =
<brainacid> print_string "I'm a lumberjack, and I'm okay. \n";
<brainacid> print_string "I sleep all night and I work all day. \n";;
<brainacid> oops
<brainacid> using String.length("monje") write a function that justifies the argument to the right 70 columns
<ggole> Do you understand what "justify" means in this context?
<brainacid> to move the text
<brainacid> I can tell it to print_string (" ");;
<ggole> So
<brainacid> but that is not clean or programming
<brainacid> i think
<ggole> The first thing is to figure out how many spaces you need to insert at the front to do the job
<brainacid> i have to get over the frustration that this causes me first in order to think clearly lol
<brainacid> correct
<brainacid> im working on it as we chat
<brainacid> trying hard to figure it out
<ggole> Well
<ggole> How many spaces would you need to move a string of length 1 by?
<pippijn> and next, teach him mathematical induction
<rks`> ggole: for your issue on merlin, I'll keep waiting for a day or two while hoping lehy shows up, if he doesn't then I'll see if there's something I can do about it
<brainacid> 69 spaces
cdidd has joined #ocaml
<ggole> rks`, thanks. If I get some time maybe I'll try to patch it myself.
<brainacid> i just to understand how to do it with the little bit of code i have learned thus far.
<rks`> ok :)
<ggole> brainacid, ok, now what about a string of length 2?
<brainacid> can i help debug anything? i would like to be useful
<brainacid> 68
<brainacid> where u going? i dont quite see it yet
<ggole> That should be enough to show you the pattern
<brainacid> ok
<brainacid> thanks (no sarcasm)
<brainacid> :)
<brainacid> cant get it in my skull
<brainacid> you cant use operations +-*/ with strings, right?
<adrien> you cannot
<adrien> in ocaml they have one and only one meaning: integer addition/substraction/multiply/divide
<brainacid> correct
<pippijn> adrien: well done
<adrien> sounds like I broke something? :P
<adrien> (well, I have but the fix is coming ;p )
<pippijn> :)
<brainacid> im on Functions chapter 3....cant figure out this exercise...:(
<brainacid> basiclly increase the length of a string so it looks right justified...lol
chrisdotcode_ has quit [Remote host closed the connection]
<brainacid> # String.length "home";;
<brainacid> - : int = 4
<brainacid> needs to be something like int = 74
<pippijn> why 74?
<brainacid> how to add spaces to a string
* brainacid ponders
<brainacid> right justification
<pippijn> but if you add 74 spaces, it's not right-justified
<adrien> not 76?
<pippijn> it's just indented
<brainacid> pippijn, the exercise wants me to have the word start at column 70
<pippijn> I see
<brainacid> home
<pippijn> do you know how to concatenate two strings?
<brainacid> yes
<pippijn> how?
<brainacid> let word1 ="one";; let word2 ="two" ;; print_string word1^word2;;
<pippijn> ok, you'd need () around those, but yes, right
* brainacid typed it without looking at books
<pippijn> print_string (a ^ b)
<brainacid> let word1 = ("one")
<brainacid> oh
<brainacid> cuz its a statement
<brainacid> print_string (word1^word2);;
<pippijn> let a = "one";; let b = "two";; let together = a ^ b;;
<pippijn> ok, so your idea was to have a string of 70 spaces as `a', right?
<brainacid> they want a function that uses String.length some how to get it done
<brainacid> yes that was my very first idea before getting on IRC...which I havent in years
<brainacid> I just started this morning to learn programming
Drup has joined #ocaml
<brainacid> /msg pippijn OCaml provides a standard module called String, which includes a useful function
<brainacid> called length that returns the length of a string, so the value of
<brainacid> String.length("monje")"
<brainacid> is 5.
<brainacid> Write a function named right_justify that takes a string named s as a parameter and prints the
<brainacid> string with enough leading spaces so that the last letter of the string is in column 70 of the display.
<brainacid> # right_justify('monje')
<brainacid> monje
<brainacid> I hope i didnt spame the room
<brainacid> pippijn,did u receive that text?
<pippijn> yes, in the room
<pippijn> and don't message me
<brainacid> oops
<brainacid> ok
<pippijn> this is ok, but use a paste site next time
<pippijn> anyway
<brainacid> ok got it
<pippijn> your exercise wants you to have the *last* letter in column 70
<brainacid> look I appreciate the help here
<pippijn> that means, it *ends* in column 70
<pippijn> not starts
<brainacid> ok
<brainacid> what confuses me is the module String
<brainacid> how can I add spaces by know the length...i mean easy subtraction yes...but is it that simple and im over complicating
<pippijn> it is that simple
<brainacid> ok
<brainacid> so
<pippijn> you don't need to create a new string, though
<pippijn> it just wants you to print the string
<pippijn> so it suffices to have a loop that prints one space at a time
<pippijn> N times, where N is the number of spaces you want to print
<gour> brainacid: imagine you have box with 70 empty slots. first (70-length(string)) are supposed t obe empty and then in the remaining slots you put each char in one slot
<brainacid> let right_just s = print_string " "^s;; right_just ("home");;
<pippijn> no
<pippijn> brainacid: the last character should be in column 70
<pippijn> so 'e' should be in 70, 'm' should be in 69, 'o' in 68 and 'h' in 67
<brainacid> yes yes
<brainacid> but Im sorry I cant see how
<brainacid> Give me some time
<brainacid> I dont any of u to get aggrevated
<brainacid> *want
<pippijn> how many spaces do you have to print so that 'h' of "home" ends up in column 67?
<gour> you 'create' (for printing) new string consisting of empty_spaces + string, all to fit in 70 slots
<pippijn> gour: not necessary
<pippijn> a loop printing the number of spaces is enough
<gour> pippijn: that why i put create in quotes
<pippijn> ok
<adrien> (for slightly later there is a solution with String creation + copy to that string; I have to leave but it will be an interesting one I think)
<brainacid> well heres the thing pippijn i havent learned loops yet and it wants me use the code learned in these first 3 chapters
<pippijn> ah
<pippijn> have you learnt about String.make?
<brainacid> greenteapress.com/thinkocaml/thinkocaml.pdf
<brainacid> nope
<brainacid> just let in print_string int_of_string float_of_int
<pippijn> hm
<brainacid> something about Currying functions
<pippijn> and "if"?
<brainacid> the thing also is there are no answers in the book...no if
<pippijn> then I don't know
<brainacid> its all good
<brainacid> can i add length by using the return value of the String.lenght module? or is that more advanced
<pippijn> you cannot change the length of a string
<pippijn> you can only create a new one
<gour> brainacid: yes, you should use length according to the book
<brainacid> yeah gour but I cant see the code in my brain...oh well...ill keep trying
<pippijn> I can't see it, either
<gour> the book spoke about length and concat. of strings, that's enough, right?
<pippijn> gour: let, in, print_string, int_of_string, float_of_int, currying functions, String.length
<pippijn> with this toolset, I don't know how to do it
<pippijn> brainacid: what about recursion?
<pippijn> brainacid: functions calling themselves
<pippijn> no
<pippijn> still not, there is no "if"
<gour> if does not say you can't produce new string
<pippijn> how do you produce a string of length n?
<brainacid> recursion...functions calling functions has been done so far
<pippijn> yeah, but without "if", that doesn't help
<brainacid> copy that
<Drup> pippijn: why do you need a if ?
* brainacid continues to have fun with IRC and Ocaml
<Drup> String.make, concatenate, print
<pippijn> Drup: String.make is not in the toolset
<pippijn> 16:01 < pippijn> have you learnt about String.make?
<pippijn> 16:02 < brainacid> nope
<Drup> oh
<brainacid> what about ...
<pippijn> brainacid: maybe you should read the preceding chapters again
<pippijn> trying to understand properly what each of them says
<brainacid> yes i am doing that as well
<pippijn> you might have missed something
<brainacid> reviewing and using toploop
<pippijn> because with what you say here, it can't be done
<brainacid> that right ? toploop
<pippijn> toploop, yes
<chris2> the first chapter mentions printf, but that would be nasty for a newbie...
<pippijn> if it doesn't mention %*s, it's not useful
<adrien> brainacid: toploop/toplevel/repl/...
<adrien> brainacid: many names to name the "ocaml" executable
<adrien> to name what it does rather
<chris2> duh
<chris2> the python version of the book mentions 'foo'*3...
<chris2> the ocaml version says it doesnt exist
<brainacid> chris2, correct operations with strings = void() lol
<brainacid> i started to learn programming @ 4am today
<brainacid> i know its going to take dedication
<chris2> brainacid: you can't know the answer yet. skip the question and come back after chapter 5
<pippijn> oh no, the book is broken
<gour> brainacid: jsut see how you're progreessing by chris2's mercy ;)
talzeus has joined #ocaml
<gour> brainacid: have you tried to take a look at realworldocaml.org book?
<pippijn> is there an open source book?
<pippijn> that would be nice
<pippijn> people could collaborate and fix bugs like that
<gour> RWO is one
<pippijn> nice
f[x] has joined #ocaml
<brainacid> gour, nope
<brainacid> i get syntax error with that
<brainacid> but i managed to get this to work like this
<gour> how do you know how many spaces you need?
<gour> brainacid: take a look to check how do you like it: https://realworldocaml.org/beta3/en/html/
<brainacid> actually i didnt work lol
<gour> brainacid: i also wonder why ocaml?
<brainacid> gour, the 'functional' pat of the book got me
<brainacid> *part
<gour> brainacid: ok, take a look at RWO
<brainacid> How to think like a (functional) programmer
<brainacid> ok
<orbitz> i like to oat, oat, oat, opples and bononos
<brainacid> Real World OCaml is aimed at programmers who have some experience with conventional programming languages
<brainacid> pasted from book
<brainacid> I my friends dont know anything
<brainacid> lol
<orbitz> that's a shame
<gour> brainacid: well, the book is more oriented towards functional part, so not having experience with imperative programming might be advantage for you for npt being spoiled ;)
demonimin has quit [Ping timeout: 245 seconds]
<orbitz> oh hai gour
<gour> brainacid: just go through for a while and see
<brainacid> thats a good point
<brainacid> i will go back and look then
demonimin has joined #ocaml
brainacid has quit [Quit: HydraIRC -> http://www.hydrairc.com <- Wibbly Wobbly IRC]
<adrien> gildor: btw, I made a patch that fixes my issue with findutil's FileUtil.find and symlinks; I had to change quite a lot of things and I've updated the testsuite but I need to go over the changes once more because I'm not completely happy with some bits of it
Kakadu has quit [Quit: Konversation terminated!]
Kakadu has joined #ocaml
travisbrady has joined #ocaml
demonimin has quit [Remote host closed the connection]
demonimin has joined #ocaml
travisbrady has quit [Quit: travisbrady]
Yoric has joined #ocaml
UncleVasya has joined #ocaml
oriba has joined #ocaml
talzeus has quit [Remote host closed the connection]
talzeus has joined #ocaml
shinnya has quit [Ping timeout: 252 seconds]
talzeus has quit [Ping timeout: 264 seconds]
brainacid has joined #ocaml
<brainacid> i still havent figured it out
<brainacid> going to try another
ollehar has quit [Ping timeout: 252 seconds]
Kakadu has quit [Ping timeout: 246 seconds]
f[x] has quit [Ping timeout: 264 seconds]
<brainacid> is this incorrect
<brainacid> let x = let y = "\s"^x;;
<brainacid> i want to put a space in front of....i meant let spc x = let y = "\s"^x;;
<Drup> brainacid: you don't need \s, just put a space
<brainacid> got it
<brainacid> but how do i pass that to the parameter given to the function?
<brainacid> its giving a Syntax error
<Drup> why do you have the y variable ?
<brainacid> dunt no
<brainacid> ii thought thats how it was written
<brainacid> so the function is to add space to its parameter
<Drup> Sure, but you don't need an additional variable
<brainacid> let spc x = ?
<Drup> just return tje result
<Drup> yes
<Drup> the*
<brainacid> ok thats where my thoughts fall
<Drup> let spc x = " " ^ x
<brainacid> that easy?
<Drup> yes
<brainacid> i was print.string (" "^x);;
Yoric has quit [Ping timeout: 264 seconds]
<Drup> print is for printing, if you want a new string with a space on front of it, you don't print
<companion_cube> or you can use Printf
<Drup> companion_cube: calm down, don't use complicate things x)
<brainacid> i have just read 3 chapters of this book
<brainacid> so yeah ... im at elementary level
<brainacid> so once the function is executed the variable x is erased right
<Drup> no
<Drup> well, that depends what you mean
<brainacid> check this pastebin
f[x] has joined #ocaml
<companion_cube> Drup: hey
<Drup> brainacid: you didn't link anything ;)
<companion_cube> you think it's complicated ? :)
<Drup> companion_cube: No, I thing he just started programming and still struggle with ocaml syntax and function application.
<Drup> brainacid: so, yes, the variable "x" you used in the function declaration is only available inside the function.
<Drup> companion_cube: think*
<companion_cube> oh, ok
<companion_cube> my bad then
<brainacid> its gravy man
<brainacid> i might be getting ahead of the book im reading with these questions
<brainacid> i just always thought I could write code and be useful to the IT world
<pippijn> it's not bad to get ahead of the book
<brainacid> but life has tossed me around like a cheap prostitute
<pippijn> you can always go back
<brainacid> yup...its a little frustrating because these simple things are taking time to learn ... cant imagine whats ahead
<pippijn> simple things take more time to learn than what's ahead
<companion_cube> better get the basics right
<brainacid> thanks a lot to all for the help...i sure appreacite it...if there is any debugging I would love to help so I can learn more
<Drup> pippijn: I disagree, 2 years and I still can't get my head around categories. But it's useless so that's okay I suppose :]
<brainacid> so keep me in mind everyone...im the new guy...give me the crap work...lol
<adrien> Drup: there's a limit between "what you can do" and "what is actually useful" :)
<pippijn> Drup: work on/with aldor
<Drup> pippijn: tbh, I didn't try very hard
ollehar has joined #ocaml
<brainacid> what does that mean
<brainacid> I just want to put a 2 in front
<pippijn> it means you wrote ; instead of ;;
<pippijn> oh
<Anarchos> brainacid "2"^x is a string
<brainacid> i know i am not useful
<pippijn> do, I don't know what you're doing
<brainacid> lol
<Anarchos> but the syntax a;b implys that a is of type unit
<Drup> brainacid: ";" is the sequence operator "a ; b" means "do a, then do b and return b"
<brainacid> but the function requires only ; to seperate statements and ;; to end the function. Right?
<pippijn> brainacid: in (a;b), the value of a is discarded
<brainacid> ok
<brainacid> Illumination
<pippijn> if you want to keep the value, you need to bind it to a name
<pippijn> let name = stuff in more stuff
<pippijn> stuff is "2" ^ x
<pippijn> let name = "2" ^ x in String.length name
ollehar has quit [Ping timeout: 248 seconds]
<pippijn> you can also re-use the name "x", that will hide the previously bound x
<brainacid> right
<pippijn> let x = "2" ^ x in String.length x
<brainacid> so any kind of expresion should be referenced by a variable
<brainacid> ahh...in...mmm...need to read more
<pippijn> if you want to do things to the value, yes
<pippijn> let spc x = " " ^ x
<pippijn> now, spc is a function that you can call with a string
<pippijn> spc "hello"
<pippijn> this will evaluate to " hello"
<pippijn> the value of (spc x) is (" " ^ x), so the value of (spc "hello") is (" " ^ "hello")
<brainacid> nice
<pippijn> it's like in math, when you write f(x) = 2x
<brainacid> u caould teach
<brainacid> :)
<pippijn> meaning f(x) = 2 * x
<pippijn> so if you call f(4), it means you replace all occurrences of 'x' in the function with '4'
<pippijn> giving you f(4) = 2 * 4 = 8
<pippijn> in ocaml, it's the same
<pippijn> let f x = 2 * x
<brainacid> right
<pippijn> f 4 = 2 * 4 = 8
<pippijn> simple as that :)
<pippijn> and let ... in is a way of saying "where"
<pippijn> for example, if you say
<pippijn> f(x) = y + 3 where y = x * 2
<pippijn> in ocaml, you say
<pippijn> let f x = let y = x * 2 in y + 3
<pippijn> so a series of let..in are just like a series of "where"
<brainacid> i see
<pippijn> and the last thing you write is the value of the whole thing
<pippijn> so you can make a series of intemediate computations, and you can print stuff in between, and in the end, the last expression is returned by the function
<pippijn> let f x = 3; 2; "hello"; x + 4; x * 2
<pippijn> all those things are discarded, and only x * 2 is returned
<brainacid> interesting
<pippijn> so if you want to keep any of them, you need to say "let some_name = 3 in" etc.
<brainacid> let another =4 ;;
<brainacid> in
<brainacid> ok let me go practice
<pippijn> ;; ends a top-level "sentence"
<pippijn> ;; can never come after "in", because ocaml wants to know "in what?"
<pippijn> let something in ... you need something else after "in"
<brainacid> ok
<pippijn> there are two different "let" things in ocaml, it's a little confusing
<brainacid> let f x = let y = " " ^ x in String.length (y);;
<pippijn> the toplevel let is not the same as the expression let..in
<brainacid> ?
<pippijn> yes, this is correct
<pippijn> in ocaml, we usually don't write () around things where it's not necessary
<pippijn> just `String.length x' is fine
<brainacid> where is it necessary?
<brainacid> ok
<pippijn> it's necessary to override operator precedence
<pippijn> for example: String.length x + 4
<pippijn> is the same as: (String.length x) + 4
<pippijn> if you write: String.length x ^ " world"
<pippijn> that's wrong, because it is the same as: (String.length x) ^ " world"
<pippijn> you can see how it is wrong, if you start replacing the function applications by their value
<pippijn> first, we assume that x = "hello"
<pippijn> so, String.length x = String.length "hello" = 5
<brainacid> i see
<pippijn> now we can replace that in the expression: (String.length x) ^ " world" = (String.length "hello") ^ " world" = 5 ^ " world"
<pippijn> so that doesn't work, because ^ concatenates a string and another string, but 5 is a number
<brainacid> so got it
<pippijn> so in order to make it work as we want, we need () around the ^ expression
<pippijn> String.length (x ^ " world")
f[x] has quit [Ping timeout: 246 seconds]
<pippijn> this does what we want, because now x is first replaced with "hello": String.length (x ^ " world") = String.length ("hello" ^ " world") = String.length "hello world" = 11
olliefr has joined #ocaml
demonimin has quit [Ping timeout: 264 seconds]
k4nar has quit [Read error: Connection reset by peer]
<brainacid> let spc = " ";;
<brainacid> let justify x = spc ^ x;;
<brainacid> justify ("hello");;
<pippijn> no need for () there
<brainacid> ok
wolfnn has joined #ocaml
<brainacid> white space is important too right?
<ggole> No
<brainacid> u were telling me about how if you do let x = 5; 6. the value is 6
<pippijn> yes
<brainacid> but here its different because its inside a function
<pippijn> functions and values are the same thing
<pippijn> functions are values
<pippijn> and in this example with the two print_strings, the value of print_lyrics () is ()
<pippijn> because the second print_string returns ()
<pippijn> () is the unit value
<pippijn> side-effects are performed regardless of the returned value
<pippijn> print_string returns (), but performs the side-effect of printing something
<pippijn> the first () is discarded (which is ok, because () is useless, anyway) and the second one is returned
<brainacid> this is what I got so far pippijn
<brainacid> but the length of string is unchanged
<pippijn> yes
<brainacid> figured it out
<pippijn> strings don't change
<pippijn> ok, you got it?
<brainacid> i think
<brainacid> yup
<brainacid> I count 58 col
<brainacid> just add more spaces
<brainacid> thats the end
<brainacid> i think thats the way to do this exercise
<brainacid> of right justified
<pippijn> yeah, it's not, but it's fine for now
<pippijn> because the book didn't teach you enough to solve it properly, yet
olliefr has quit [Read error: Connection reset by peer]
<brainacid> lol
nikki93 has joined #ocaml
wolfnn1 has joined #ocaml
wolfnn has quit [Ping timeout: 240 seconds]
<brainacid> im trying to make a box
nikki93 has quit [Remote host closed the connection]
<adrien> a box?
<companion_cube> brainacid: do you mean a mutable box, like a reference?
<brainacid> ascii art
<brainacid> i cant get the newline
<brainacid> how can i do that but using a variable to replace the parameters
<brainacid> say drawbox ();; and a ascii art comes out
<Drup> brainacid: your code is ok, it's just a string. To see \n as newlines, you need to print it
<Drup> print_string (drw "+---+---" "| | ") ;;
<brainacid> i see
<brainacid> i should store the patter in a variable
<brainacid> or make it a function
<brainacid> like this?
<Drup> yes
<brainacid> hold on
<brainacid> actually is this it
<Drup> almost, your forgot some ^
<Drup> and some parenthesis
<brainacid> failed on all of my code
<brainacid> error
<brainacid> latest code
tane has joined #ocaml
<brainacid> i got nothing
<Drup> brainacid: remember what pippijn told you about paranthesis and priority
travisbrady has joined #ocaml
<brainacid> im trying to remember all things
<brainacid> :)
rndm has joined #ocaml
<rndm> what is the [< >] syntax used here? http://llvm.org/docs/tutorial/OCamlLangImpl1.html#language
<Drup> rndm: streams
<rndm> it looks like some kind of matched decomposition of a stream into head, tail?
<companion_cube> it's a syntax extension for streams
<rndm> if i wanted to find the documentation or other examples of that? what's the best place to look? it doesn't appear to be in the streams section of the ocaml tutorial
<rndm> oh. but it is in the "streams expression" section. i see. sorry about that :)
<brainacid> i might be better off learning python
<brainacid> whats the word here? OCaml good for green newbies
<brainacid> it seems im having such a difficult time understanding
<Drup> brainacid: The first programming experience would probably be as difficult in most languages
<brainacid> understood
travisbrady has quit [Quit: travisbrady]
<brainacid> well...let me continue reading
<brainacid> maybe my text is not worth it....
<brainacid> Howt to Think like a (functional) programmer by greentea press
<Drup> it's probably not a good intro to programming in general
<Drup> (according to the title, I don't know the book)
<brainacid> its actually supposed to be the best intro to programming
nikki93 has joined #ocaml
<brainacid> How to Think Like a Computer Scientist is an introductory programming textbook based on the OCaml language. It is a modified version of Think Python by Allen Downey.
<brainacid> It is intended for newcomers to programming and also those who know some programming but want to learn programming in the function-oriented paradigm, or those who simply want to learn OCaml.
<gour> maybe it is Learn The OCaml Hard Way :-)
<brainacid> yup
<brainacid> anyone understand currying
wwilly has quit [Remote host closed the connection]
<gour> brainacid: wha kind of background you have in math?
<gour> *what
UncleVasya has quit [Read error: Connection reset by peer]
UncleVasya has joined #ocaml
<mrvn> brainacid: just think of "fun x y z" as "function x -> function y -> function z -> ". No magic neccessary.
<mrvn> unless you are writing a compiler you don't have to think about currying.
<brainacid> i got it!!!
<brainacid> its an exercise in my book
<brainacid> :D got it
ulfdoz has quit [Ping timeout: 252 seconds]
ggole has quit []
<mrvn> sure it isn't an exercise in partial application?
snearch has joined #ocaml
<adrien> I'm not sure brainacid is there yet :)
<brainacid> Now use currying with that function to de?ne functions that append + and - to the end of the string,
<brainacid> again with a space in between.
<brainacid> Finally, write a function to append a symbol x number of times.
<brainacid> *define
<brainacid> I dont have it correct
<brainacid> the last one i dont know yet. appending a symbol x num of times
<brainacid> is it saying to append like this ... + hello world -
<mrvn> what has any of that got to do with currying?
<brainacid> above
<brainacid> use currying to define other functions
<mrvn> you can use partial application to add a "+" to the front. But the rest needs full application.
<brainacid> yes i got that but i dont understand adding the _ to the end and getting + hello world_
<brainacid> the last pastebin is what I read
darkf has joined #ocaml
<mrvn> brainacid: you can't with partial application. You have to do full application because your const part (-) is the last argument.
<technomancy> how would I link libffi statically as suggested here? http://lists.ocaml.org/pipermail/ctypes/2013-October/000012.html
<technomancy> (possibly ctypes-specific; I don't know much about C libraries)
<brainacid> i see
<gour> the book says: "This is called ‘currying, after Haskell Curry. It is also sometimes called partial application." according to that paste, but those are not really the same, iirc
<brainacid> but i still dont get it ... on how to code it
<brainacid> copy that
<mrvn> brainacid: let bla x = fcon x "-"
<gour> RWO also makes distinction...
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
olliefr has joined #ocaml
zpe has joined #ocaml
<mrvn> gour: afaik currying is what the compiler does to make it work. partial application is what you do to take advantage of it.
Yoric has joined #ocaml
zpe has quit [Remote host closed the connection]
<gour> mrvn: RWO puts it as: "The practice of applying some of the arguments of a curried function to get a new function is called partial application."
<mrvn> gour: excatly.
<mrvn> Somehow I don't even get why people make such a deal about currying in a functional language. Functions are first class so partial application comes totaly natural.
<mrvn> The actual hard part, imho, is uncurrying functions.
<companion_cube> depends on whether the syntax makes it easy to curry
<mrvn> Optimizing the compiler output for when a full application is used, or just multiple arguments at once.
<mrvn> companion_cube: fun x y z is just a syntactic suggar for function x -> function y -> function z. You can do that trivially while parsing.
<companion_cube> mrvn: in OCaml, yes.
<mrvn> in any functional language
<companion_cube> languages like scala don't have such a nice syntax
<mrvn> as soon as function are first class objects you can trivial do it
<companion_cube> of course you can write it, but it's less convenient, the default is uncurried
<companion_cube> my point is easyness, not doability
<mrvn> companion_cube: My point is that you can always write the function in curried form manually so the compiler already needs to support curried functions. Actually supporting uncurried functions takes extra work.
<companion_cube> unless you accept tuple arguments as uncurried :)
<mrvn> companion_cube: fun (x,y,z) -> x + y + z. That takes extra work because you have to unpack the tuple.
nikki93 has quit [Remote host closed the connection]
<companion_cube> OCaml's abstract machine doesn't do uncurried, but it optimizes for the case where all arguments are present
Yoric has quit [Remote host closed the connection]
<companion_cube> if tuples are by value that's fine
Yoric has joined #ocaml
<brainacid> well guys...im super green. never coded
<brainacid> I appreciate the help
<mrvn> brainacid: keep on reading. don't get discouraged.
<brainacid> I will not. I shall push on trukin
<brainacid> could u shed some light mrvn
<brainacid> how to append a symbol multiple times?
<brainacid> i just dont see it...with the limited tool box they gave me
<mrvn> with a for loop or recursion
<brainacid> well im in chapter 3 and its very basic
<brainacid> i think its recursion
nikki93 has joined #ocaml
<brainacid> but the only string maipulation tools they showed so far is ^
<brainacid> thats it
<mrvn> something like: let rec times a b = function 0 -> a | n -> fcon (times a b (n-1)) b
<brainacid> it would have to be the simple basic code
<gour> brainacid: again, i recommend you to read RWO 'cause it is long time available for review and commenters were taking care that the material is not presented prematurely not covering everything what is required which does not seem to be the case with 'your' book
<mrvn> let rec times a b n = if n = 0 then a else fcon (times a b (n-1)) b
<brainacid> i see
<brainacid> its just a terse read
<brainacid> so far
<brainacid> im in the guided tour
<mrvn> brainacid: have you done a factorial function yet?
<brainacid> no
<mrvn> then how did they introduce recursion?
<Drup> mrvn: I think he didn't saw recursion yet ...
<gour> that's good, you will get feeling for the language without the need to understand everything. then, starting with chapter two, you will get 'aha moments' ;)
<brainacid> it was simply mentioned that during recursion i would love currying. Excuse my mistake
<brainacid> Sweet! gour
<brainacid> I will start and quit botherin you nice folk
<brainacid> ;)
<gour> brainacid: do you have ocaml compiler installed to try examples
<mrvn> brainacid: odd. I don't see partial application as relevant for recursions that much.
<brainacid> I installed the whole package from the site ... for winblows 8
<gour> don't just read, but try as well ;)
<brainacid> I also have ubuntu linux
<gour> wih linux it would be easier
<gour> as far as rWO book is concerned
* brainacid fires up the Pentium 4
<gour> bear in mind to check Appendix in RWO to install some extra stuff required
<brainacid> copy that...@ appendix now
<gour> brainacid: and have fun ;)
<mrvn> brainacid: for most concepts it is hard to find a good standalone examples that is just a few lines.
* gour is ocaml noob as well
<mrvn> some things you just have to learn blindly and accept and over time you will start to value them.
<mrvn> (or not, that is ok too)
<mrvn> Some things come down to taste.
<brainacid> I wish i kept going when I was 14. I started Perl back then on RedHat 6 or 4...cant remember
<brainacid> I wanted to be 31337 hax0r...white hat of course
<brainacid> lol
<brainacid> ocaml installing on my loud Western Digital.
* gour --> sleep
<gour> 'night folks
<pippijn> brainacid: I started programming at 19
gour has left #ocaml []
<pippijn> so yeah
<pippijn> no need to wish for having done something
Cypi has quit []
Cypi has joined #ocaml
UncleVasya has quit [Remote host closed the connection]
<technomancy> it looks like running `ocamlbuild -use-ocamlfind mycode.byte` with opam hard-codes the opam-installed location of ocamlrun into the bytecode?
Cypi has quit [Client Quit]
Cypi has joined #ocaml
demonimin has joined #ocaml
<adrien> technomancy: yes, it's a shebang
<technomancy> ah, I can just fix it in emacs
<adrien> but you can still /whichever/ocamlrun/you/want foo.byte
<technomancy> is there a way to get ocamlbuild to emit portable .byte files though?
<adrien> there's also the custom mode which is basically "cat ocamlrun foo.byte > foo.exe" but it's best avoided nowadays
<technomancy> if I have to do it by hand I'll surely forget eventually
<adrien> they're portable
<adrien> you'd like a different shebang?
<technomancy> interesting definition of portable =)
<technomancy> I'd like something that works on someone else's machine, yeah
<adrien> technomancy: but generally-speaking, don't mix different compiler bits
<adrien> you could emit bytecode which use primitives that aren't available with another ocamlrun
<technomancy> according to the Debian OCaml guide, bytecode versions are portable
<adrien> they're portable but if your bytecode uses "cos" and you have a VM that doesn't provide "cos", it won't work
<adrien> but how would be the shebang you'd like?
<adrien> there's maybe -use-runtime
<adrien> but I've never used it
<technomancy> changing it to #!/usr/bin/env ocamlrun does the trick
<brainacid> pippijn, im 29 now
<technomancy> if I specify I need ocaml 4.x and compile under 4.00.1 that seems pretty safe
<brainacid> pippijn, Im on Ubuntu 12 Precise...Im having issues getting OPAM. I added the repository and ran all the commands. Says package not found
<pippijn> oh
<pippijn> I'm on precise, too
<pippijn> you need to download the package manually
<pippijn> opam and opam-doc (or -docs)
<adrien> technomancy: I think you can say >= $version instead of = $version
<adrien> technomancy: most people have a Makefile to invoke ocamlbuild anyway; you would do that
<technomancy> adrien: where would that be specified?
<technomancy> hm; ctypes seems to complicate things; a foreign_stubs.so path is also hard-coded in =\
<adrien> "make" is shorter to type than "ocamlbuild foo.byte" :P
<adrien> LD_LIBRARY_PATH should do it
<adrien> I think it's also something you'd chose with -dllpath or a name that is similar
<pippijn> (assuming you're on amd64)
<technomancy> adrien: thanks; I think I'm in way over my head with ctypes... the docs don't really cover any of this stuff
<brainacid> Pentium 4
<brainacid> lol
<brainacid> thanks bro
<brainacid> got 'em
olliefr has quit [Ping timeout: 260 seconds]
<adrien> technomancy: check "man ocamlc", there's a -dllpath option and a -use-runtime option too
<adrien> and there are command-line options and environment variables for ocamlrun too
<technomancy> adrien: thanks. I guess I need to figure out how ocamlbuild passes args to ocamlc?
<adrien> technomancy: btw, the typical way to share binaries across distributions is to have a wrapper script anyway (to set LD_LIBRARY_PATH, PATH, env vars, ...)
<adrien> (web browsers love to abuse that)
<technomancy> yeah, I do that on the JVM for clojure; it's kind of a pain =\
<adrien> for ocamlbuild, I don't remember but I'm sure that others here do
<adrien> yeah, annoying but you should only need a couple lines
<adrien> going to bed, good night
olliefr has joined #ocaml
Yoric has quit [Remote host closed the connection]
snearch has quit [Quit: Verlassend]
zpe has joined #ocaml
Kakadu has joined #ocaml
Yoric has joined #ocaml
olliefr has quit [Ping timeout: 260 seconds]
Kakadu has quit [Client Quit]
zpe has quit [Ping timeout: 248 seconds]
zpe has joined #ocaml
Yoric has quit [Ping timeout: 264 seconds]
shinnya has joined #ocaml
zpe_ has joined #ocaml
zpe has quit [Ping timeout: 245 seconds]
csakatoku has joined #ocaml
zpe_ has quit [Remote host closed the connection]
tane has quit [Quit: Verlassend]
<brainacid> what kind of programs are coded in OCaml?
<brainacid> and what potential does it have?
<brainacid> anone
<brainacid> & n e 1
csakatoku has quit [Remote host closed the connection]
csakatoku has joined #ocaml
nikki93 has quit [Remote host closed the connection]
csakatoku has quit [Ping timeout: 240 seconds]
<brainacid> pippijn,I did it!
<brainacid> pippijn,It just came to me
<pippijn> good :)
<brainacid> i cant explain how
<brainacid> it flowed out
<brainacid> still installin on my linux box...at final stages now
Anarchos has quit [Quit: Vision[0.9.7-H-280704]: i've been blurred!]
csakatoku has joined #ocaml
csakatoku has quit [Ping timeout: 245 seconds]
wolfnn1 has quit [Ping timeout: 246 seconds]
<brainacid> on Ubuntu Precise...I cant get utop to run
<brainacid> i guess i am stuck with learning ocalm on windows
<brainacid> later yall
brainacid has quit [Quit: HydraIRC -> http://www.hydrairc.com <- It'll be on slashdot one day...]
breakds has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 268 seconds]
q66 has quit [Quit: Leaving]
oriba has quit [Quit: oriba]
nikki93 has joined #ocaml
mfp has quit [Ping timeout: 264 seconds]
r00s has joined #ocaml