mrsolo has quit [Read error: 104 (Connection reset by peer)]
khaladan has quit [Connection timed out]
int80_h has joined #ocaml
<int80_h>
hi people :)
<zmdkrbou>
yo
descender has quit ["XML is like violence, if it doesn't solve the problem, just use more."]
* dylan
mutters "I will do homework, not add list comprehensions to my toy language"
<int80_h>
hmm
int80_h has quit ["[BX] Reserve your copy of BitchX-1.0c18 for the Nintendo Gameboy today!"]
slipstream has quit [Read error: 110 (Connection timed out)]
khaladan_ has quit [Read error: 104 (Connection reset by peer)]
slipstream has joined #ocaml
dark_light has quit [Read error: 110 (Connection timed out)]
mikeX has left #ocaml []
Submarine has quit [Connection timed out]
easy4 has joined #ocaml
dark_light has joined #ocaml
dark_light has quit [Connection timed out]
dark_light has joined #ocaml
easy4 has quit [Remote closed the connection]
easy4 has joined #ocaml
Smerdyakov has quit ["Leaving"]
dark_light has quit [Read error: 110 (Connection timed out)]
easy4 has quit [Read error: 110 (Connection timed out)]
dark_light has joined #ocaml
TaXules_ has quit [Read error: 104 (Connection reset by peer)]
TaXules has joined #ocaml
dark_light has quit [Remote closed the connection]
TaXules_ has joined #ocaml
TaXules has quit [Remote closed the connection]
_fab has joined #ocaml
pango is now known as pangoafk
joshcryer has quit [Read error: 104 (Connection reset by peer)]
GCarrier has joined #ocaml
<GCarrier>
hi!
<GCarrier>
is there a function to check is a character is "downcase", like [a-z] but not [A-Z] please?
<flux__>
I don't know, but if you don't care about locales, match 'a' with 'a'..'z' -> true | _ -> false would work
<GCarrier>
yep
<GCarrier>
thx ;)
m3ga has joined #ocaml
joshcryer has joined #ocaml
GCarrier has quit ["Ex-Chat"]
love-pingoo has joined #ocaml
ppsmimou has quit [niven.freenode.net irc.freenode.net]
ppsmimou has joined #ocaml
Snark has joined #ocaml
m3ga has quit ["disappearing into the sunset"]
pangoafk is now known as pango
TaXules_ is now known as TaXules
Skal has joined #ocaml
descender has joined #ocaml
cmeme has quit [Connection timed out]
cmeme has joined #ocaml
pango is now known as pangoafk
Schmurtz has joined #ocaml
GCarrier has joined #ocaml
Skal has quit [Remote closed the connection]
Schmurtz has quit [Read error: 110 (Connection timed out)]
GCarrier has quit ["Ex-Chat"]
ulfdoz has quit [niven.freenode.net irc.freenode.net]
ulfdoz has joined #ocaml
love-pingoo has quit ["Leaving"]
VB has joined #ocaml
Skal has joined #ocaml
pauldia has joined #ocaml
VB has left #ocaml []
ski has quit [Read error: 110 (Connection timed out)]
ski has joined #ocaml
Smerdyakov has joined #ocaml
GCarrier has joined #ocaml
love-pingoo has joined #ocaml
bluestorm has joined #ocaml
ski has quit [Read error: 110 (Connection timed out)]
GCarrier has quit [Remote closed the connection]
GCarrier has joined #ocaml
<GCarrier>
#xorg
<GCarrier>
sorry
bluestorm has quit [Remote closed the connection]
ski has joined #ocaml
bluestorm has joined #ocaml
ramkrsna has quit [Connection timed out]
smimou has joined #ocaml
mikeX has joined #ocaml
ski has quit ["later"]
pangoafk is now known as pangoafkafk
pangoafkafk is now known as pangoafk
bluestorm has quit [Read error: 113 (No route to host)]
pangoafk is now known as pango
GCarrier has quit [Read error: 113 (No route to host)]
GCarrier has joined #ocaml
tspier2 has joined #ocaml
<tspier2>
Hello
<tspier2>
Is everyone busy?
<mikeX>
tspier2: just ask
<tspier2>
Okay, well I'm gonna try compiling a program I was writing today, and if it doesn't work, I'm gonna try to debug it. If it still doesn't work, would you mind if I gave you a link and asked for help, mikeX?
<mikeX>
well there's no need to ask me personally, you can paste the link, so anyone can help you
<tspier2>
It might look really bad, because I did just start OCaml about a week ago.
<pango>
functions are defined with "let", not "let func"
<pango>
"try" is a reserved word
<tspier2>
Ah
<mikeX>
and there already exists a function named incr, which incements int refecerences
<mikeX>
let i = ref 0 in incr i;;
<mikeX>
now i is ref 1
<mikeX>
(so you might want to choose a more appropriate name)
<tspier2>
So if I change "let func" to "let", change "try" to "eval", and change "incr" to "bump_one", do you think it will work?
<mikeX>
well you can leave incr as is, but it will hide the previous declaration
<pango>
ocaml doesn't allow defining functions the way you tried with "try" (with 3 separate definitions); You need to provide a single definition, handling pattern matching yourself
<tspier2>
Will the program evaluate the numbers 0-500, divide each of them with 3, 4, and 5, and then print out the respective message, and loop if the number hasn't reached 500 yet?
<pango>
as is, there's still a long way to go
<tspier2>
Ah
<tspier2>
Should I just dump it, and start new?
<pango>
/ returns the result of integer division, to check divisibility you must check that modulus (rest) is 0
<tspier2>
Oh
<pango>
let divisible n k = (n mod k = 0) (or something like that)
<tspier2>
So...let divisible n 3 = (n mod 3 = 0)
<tspier2>
That would work?
<pango>
that would create a function 'divisible', that would check if its first argument is a multiple of 3 if its second argument is 3, or raise a match failure otherwise (= including if the second argument is not 3)
<tspier2>
Gah
<pango>
you can define a function called, say, divisible3 to check for multiples of 3 (let divisible3 n = (n mod 3 = 0)), but what's wrong with the function I provided ?
<tspier2>
Uh
<pango>
I don't think ocaml compiler can make n mod 3 much faster than n mod k
<tspier2>
So I should just use (let divisible3 n = (n mod 3 = 0)), because it would define the function as divisible 3, and perform the value of n divided by three to see what is left, and to check if it is zero...right?
<pango>
no, 'divisible' already does that, and returns a boolean value
<pango>
# let divisible n k = (n mod k = 0) ;;
<pango>
val divisible : int -> int -> bool = <fun>
<mikeX>
tspier2: are you using the toplevel interpreter?
<mikeX>
it's ideal for trying things out step by step
<tspier2>
Oh, how would I install/use it on Windows? Normally I use Linux for it...
<mikeX>
the mingw binary has it as far as I know
<tspier2>
Oh
<tspier2>
Do you think I can have this done by tomorrow?
<mikeX>
what exactly?
<tspier2>
I want to make it calculate which numbers between 1 and 500 can be divided by 3, 4, and 5 to get integer values, and not floats. Then later on, I want to add a small function to output it, which I know how to do that.
<pango>
there's still some problems with your code; Main one remaining is that you use n as if it was mutable
<pango>
but it is not; if you don't use references, you can redefine n, but not modify it
<pango>
another lesser problem is that print_endline expects a string; So you either have to write print_endline ((string_of_int n) ^ " is not divisible by 3, 4, or 5.") or Printf.printf "%d is not divisible by 3, 4, or 5.\n" n
<tspier2>
Oh
<tspier2>
Let me try writing it again...
<pango>
btw, there's no "floats" involved. / is "euclidian division", its result is an integer, always
<mikeX>
i'm not sure if that's what you want to do really
<tspier2>
Hmm
<pango>
tspier2: "in" at the end of line 1 makes number_of_series a local definition of bump_one; so number_of_series is not defined in the remaining of your program
<tspier2>
It looks like it checks if the number can be divided by 3, 4, and 5, and if it is greater than or smaller than zero, it prints the message saying it isn't. Likewise for if it does, but why do you have (n-1), when it should be increasing by one. Example...it should go from 1 to 2, not 2 to 1.
<pango>
tspier2: mikeX is checking numbers in reverse order, starting from 500 and back to 1
<tspier2>
Oh
<tspier2>
So what he put would work?
<pango>
tspier2: his program looks correct
<pango>
testing numbers in increasing order shouldn't be much more complicated
<tspier2>
So I should get rid of "in" from the first line, and insert his code into number_evaluation?
<tspier2>
Then it would work?
<pango>
;; should only be used when you're back to "toplevel" (if at all; it can be totally avoided in compiled programs). For example, you shouldn't have ;; at the end of line 8 (before 'else') because current function definition is not finished yet at that point
<mikeX>
the program works, I just wasn't sure if that's what you wanted exactly
<pango>
ok, the problem is now that number_of_series is a reference, so you need to write !number_of_references to get the integer value it references
<pango>
!number_of_series > 500, etc.
<tspier2>
Okay, just changed it.
<pango>
lines from 13 onward are mikeX's program, so you pasted 2 programs btw
<tspier2>
Yeah
<pango>
you didn't close parenthesis opened at the end of line 8
<tspier2>
I did at 12.
illya23b has quit [Read error: 110 (Connection timed out)]
<pango>
mmh well, you did, but at the wrong place :)
<pango>
it should be before 'in'
<tspier2>
Oh
<pango>
function definition stops at that 'in'
<tspier2>
Question...could I put this in place of Printf.printf "%4d blah..." and print_endline "Finished" to have it create the files and output the text...let o = open_out "Divisible.txt";;
<tspier2>
output_string o n && " is divisible by 3, 4, and 5.\n";;
<tspier2>
close_out o;;
<tspier2>
Likewise for the not divisible one
<pango>
&& is a boolean operator
<pango>
you can use ^ to catenate strings you want to output
<tspier2>
So, I would use ^ in place of the &&, and it would output them?
<pango>
or use Printf.fprintf to send formatted output to an open channel
<pango>
tspier2: and parenthesis around the (string ^ string), because of priorities
<pango>
not to mention replace n with (string_of_int n)... there's *no* implicit conversions in ocaml
<mikeX>
tspier2: you can install this on windows if you want
<dylan>
tspier2: If you immediately know the candle light is fire, then the meal was cooked a long time ago. :)
<tspier2>
Why is OCaml so difficult?
<tspier2>
People say that it is easy, but I feel like killing myself.
<pango>
because you have to unlearn a lot
<tspier2>
Maybe I should've just stuck with imperative?
<pango>
depends whether you want to learn different ways of thinking about programming or not
<mikeX>
tspier2: I found it quite difficult at first
<tspier2>
I'm not getting anywhere though, and if I can't do that stupid program, then I can't get extra credit in math, unless I actually write it all out.
<mikeX>
I don't think becoming familiar with a different programming paradigm under pressure is a good idea
<mikeX>
it's a good thing to have a motivation (a project to work on in ocaml), but not time pressure
<tspier2>
I've been looking over those books for two weeks now, and I'm not getting anywhere.
<pango>
I think they're two kinds of difficulties there, concepts and syntax
<pango>
ocaml syntax can be confusing sometimes, but it 'just' takes time to get used to it
<mikeX>
i agree with pango
<mikeX>
and I'm relatively new to ocaml, so the experience is still fresh in my mind
<pango>
concepts is something different, sometimes hard to 'get' out of a book; did you get any introduction to functional programming ?
<pango>
I mean, did they teach something about that paradigm ?
easy4 has joined #ocaml
<tspier2>
No
<tspier2>
Maybe I'd learn better if I didn't have so much stress, but there is no getting around it.
<pango>
so, and no offense intended, I'm not too surprized that you find it difficult. It's not "just a different syntax"
<tspier2>
pango: do you think I could learn enough tonight to be able to create that application myself?
<pango>
hard to tell... it seems that syntax is slowly getting in... I'm not so sure about fp, maybe that's what you should look at more deeply now
<tspier2>
Forget about the whole divisible thing for now, let me give you a new example, so I can see if I understand properly...
<tspier2>
Let's say I want the user to enter any values they want. Let's say they gave me, 10, 12, 15, 27, and 59. How would I be able to parse those numbers, so the output would look like this...
<pango>
it's better if it doesn't involve inputting or outputting strings, because i/os are basically imperative constructs
<tspier2>
1 | 0 2 5
<tspier2>
2 | 7
<tspier2>
5 | 9
<pango>
plain computations may prove easier
<pango>
(not to mention I don't understand your example ;) )
<tspier2>
You've never done stem and leaf plots?
<pango>
again, it's possible that english terms are confusing me
<tspier2>
1 | 0 2 5 = 10, 12, 15
<tspier2>
2 | 7 = 27
<tspier2>
5 | 9 = 59
<pango>
ok
smimou has quit ["bli"]
<pango>
are input number sorted ? in 10-99 range ?
<pango>
(I don't really see how such complex example will ease undertanding)
<tspier2>
That is a complex one?
<pango>
well, it's definitely more complex than previous one, that was already a problem
<tspier2>
Oh
<tspier2>
Let me think of an easier one...
<tspier2>
You know what Range, Median, Mode, and Mean are, right?
<pango>
of a set of "numbers", I suppose
<tspier2>
Range is the highest number minus the lowest number. Median is the middle number when they are lined up from smallest to highest. Mode is the number that occurs the most. Mean is the average.
<tspier2>
Would this one be easier or harder?
<pango>
definitely easier, if you've seen ocaml lists
<tspier2>
Do you think this one would be too easy for me, or a good start?
<mikeX>
douleuei pango ?
<mikeX>
oops, wrong channel
<pango>
tspier2: you learned how to use lists in ocaml ?
<mikeX>
just split a bunch of windows in irssi and it's confusing me a little bit
<tspier2>
["blah"; "blah"; "blah"]?
<pango>
tspier2: yes
<tspier2>
Then if you have int and string, it is a tuple?
<pango>
lists and tuples are totally different beasts
<tspier2>
I know, I'm just saying.
<tspier2>
Lol
<tspier2>
pango, I don't know where you live, but if I am taking up too much time, or you have to sleep, just tell me.
<pango>
well, it's 00:51 here, but I'm not sleepy yet ;)
<mikeX>
: )
<mikeX>
(again wrong window, dammit)
<pango>
lol
<tspier2>
Heh
<pango>
lists can only contain values of the same type
<tspier2>
pango, say we have the list, ["1"; "2"; "3"; "4"; "5"], say I wanted to get the range, would I put List.tl - List.hd?
<pango>
no, because the two don't have the same type
<tspier2>
Oh, I get it. I can't have quotes, because that makes them strings?
<pango>
lists are either empty [], or constructed from a head of type 'a and a queue of type 'a list (= list of values of type 'a)
<tspier2>
I should just have [1, 2, 3, 4, 5]?
<tspier2>
Gah
<tspier2>
I mean ; instead of ,
<pango>
so head and queue don't have the same type
<pango>
for example [1; 2; 3; 4; 5] = 1 :: [2; 3; 4; 5]
<pango>
head is 1, of type int, queue is [2; 3; 4; 5], of type int list
_fab has quit [Read error: 113 (No route to host)]