<intero>
heh it's something to find the best solution in a problem
<intero>
nothing special
<intero>
i may implement that in ocaml in the next month
<intero>
so i am training
<intero>
well i'll go to sleep now
<intero>
thanks again for support, take care
<whee>
night
intero has left #ocaml []
malc has joined #ocaml
malc has quit [brunner.freenode.net irc.freenode.net]
merriam has quit [brunner.freenode.net irc.freenode.net]
malc has joined #ocaml
merriam has joined #ocaml
Kinners has left #ocaml []
malc has quit [Read error: 110 (Connection timed out)]
mattam has quit ["leaving"]
lament has quit ["<Liam> cocks || <Liam> gigantic cocks || <Liam> slapping me in the face"]
lament has joined #ocaml
listener has joined #ocaml
<listener>
Anyone here?
<listener>
How do I write a function that raises an exception.
<listener>
I tried
<listener>
exception my_ex;;
<listener>
let raise_my=raise my_ex;;
<listener>
That didn't work.
listener has left #ocaml []
mattam has joined #ocaml
asqui has quit [Read error: 110 (Connection timed out)]
intero has joined #ocaml
<intero>
hi all
systems has joined #ocaml
systems has left #ocaml []
__mattam__ has joined #ocaml
mattam has quit [Read error: 113 (No route to host)]
__mattam__ is now known as mattam
<intero>
what does '_a mean?
<smkl>
it is so called weak type variable
<smkl>
it means that there exists one type '_a that can be bound to it
<smkl>
for example: let x = ref [] => x : '_a list ref ... x := [1] => x : int list ref
<intero>
mmm
<intero>
i still dont see the huge difference between 'a and '_A
<intero>
'_a
<intero>
i mean, if it's not 'a, then why not 'b?
<intero>
thanks smkl anyway, i am a newbie :P
<intero>
later
<smkl>
say you have functions of type '_a -> '_a and type 'a -> 'a ... first time you use the first function with for example int argument, the functions type becomes int -> int .. the second functions type won't change
merriam has quit [brunner.freenode.net irc.freenode.net]
polin8 has quit [brunner.freenode.net irc.freenode.net]
whee has quit [brunner.freenode.net irc.freenode.net]
skylan has quit [brunner.freenode.net irc.freenode.net]
lindril has quit [brunner.freenode.net irc.freenode.net]
lam has quit [brunner.freenode.net irc.freenode.net]
mattam has quit [brunner.freenode.net irc.freenode.net]
Zadeh has quit [brunner.freenode.net irc.freenode.net]
Segora has quit [brunner.freenode.net irc.freenode.net]
xkb has quit [brunner.freenode.net irc.freenode.net]
Torquema1a has quit [brunner.freenode.net irc.freenode.net]
emu has quit [brunner.freenode.net irc.freenode.net]
nkoza has quit [brunner.freenode.net irc.freenode.net]
intero has quit [brunner.freenode.net irc.freenode.net]
lament has quit [brunner.freenode.net irc.freenode.net]
foxen5 has quit [brunner.freenode.net irc.freenode.net]
smkl has quit [Nick collision]
smkl has joined #ocaml
mattam has joined #ocaml
intero has joined #ocaml
lament has joined #ocaml
merriam has joined #ocaml
polin8 has joined #ocaml
whee has joined #ocaml
Zadeh has joined #ocaml
skylan has joined #ocaml
foxen5 has joined #ocaml
emu has joined #ocaml
Torquema1a has joined #ocaml
xkb has joined #ocaml
nkoza has joined #ocaml
Segora has joined #ocaml
lindril has joined #ocaml
lam has joined #ocaml
docelic|away has quit [Excess Flood]
docelic|away has joined #ocaml
clog has joined #ocaml
rox| has joined #ocaml
systems has joined #ocaml
asqui has joined #ocaml
mattam has quit [Read error: 60 (Operation timed out)]
mattam has joined #ocaml
mattam_ has joined #ocaml
mrvn_ has joined #ocaml
mattam_ has left #ocaml []
systems has quit [Read error: 110 (Connection timed out)]
dash has quit [Read error: 110 (Connection timed out)]
mrvn has quit [Read error: 110 (Connection timed out)]
lament has quit ["<Liam> cocks || <Liam> gigantic cocks || <Liam> slapping me in the face"]
<whee>
bloop
<whee>
figure out the exception stuff intero?
<intero>
yes i am done thanks
<intero>
still slow in coding though
Stapler has joined #ocaml
systems has joined #ocaml
<Stapler>
I got a question. Can I create a list of functions, aka "let batch = [fib[x], power[y], relist]" ?
<whee>
provided the functions are of the same types, yes
<whee>
you could use variants (polymorphic variants would be nice) if you needed to do other things
<Stapler>
whee: Alright. Just curious. I'm a newbie to OCaml.
<Stapler>
whee: Is there a practical limit to just how far I can take that technique?
<whee>
depends on what you're doing, I guess
<Stapler>
whee: Well, I mean, if I gave the code to someone else to peruse, I dont want them going "What the f**k are you trying to do here?". Heh.
<whee>
if the way you do it works well, then I wouldn't worry
<Stapler>
whee: Gotcha.
<Stapler>
whee: Right now I'm working on figuring out how to open a text file, chop it up, and sort the words into a dictionary/glossary.
<whee>
that one's always fun :)
<Stapler>
whee: Well, I figure it's good practice.
<whee>
there's a lot of different ways you can do the actual parsing with that
<Stapler>
First I gotta create a list of word delimiters. i.e. Space, Tab, comma, colon, etc...
systems has left #ocaml []
<Stapler>
Would I delimit the delimiters using single or double quotes? [' '; ';';',';'.'] ?
<whee>
single if you're parsing by characters
* Stapler
nods
<Stapler>
Alright, what part of the library reference do I look in for Unix file I/O?
<mrvn_>
Chapter 21 The unix library: Unix system calls
* Stapler
nods
<Stapler>
Looking it over right now.
<mrvn_>
Pretty good interface
<Stapler>
mrvn_: Quite a bit simpler than I had expected.
<Stapler>
Trying to figure out the "fprintf" interface at the moment.
<mrvn_>
Printf.printf "format" arg arg arg
<Stapler>
Do I have to explicitly do "let show = open_out : stdout;;" before I can use fprintf?
<mrvn_>
not that I now
<Stapler>
mrvn_: mind if I post up a code snippet?
<mrvn_>
no
<Stapler>
let dlst = [' ';';';',';'.'];;
<Stapler>
let x = open_in("Rev.txt");;
<Stapler>
let show = Printf.printf "%s" y;;
<Stapler>
let rec isin x dlst =
<Stapler>
match dlst with
<Stapler>
[] -> false
<Stapler>
| y :: dlst -> x = y
<Stapler>
show
<Stapler>
|| isin x dlst;;
<Stapler>
Make sense?
<mrvn_>
Unbound value y
<mrvn_>
let show () ?
<mrvn_>
let show y = ?
<Stapler>
Yup. Actually I want to show everything that does not match dlst.
<Stapler>
Trying to load in the text file Rev.txt
<Stapler>
I dont suppose I would do "let x[] = open_in("Rev.txt");;" ?
<Stapler>
And change show to "let show = Printf.printf "%s" x;;" ?
<Stapler>
errr... x[y]?
<mrvn_>
Warning: this pattern-matching is not exhaustive.
<mrvn_>
Here is an example of a value that is not matched:
<mrvn_>
_::_
<mrvn_>
val x : 'a list -> in_channel = <fun>
<mrvn_>
Never directly used in_channel.
<mrvn_>
How do you get the first element?
<Stapler>
mrvn_: Doesn't OCaml's open_in read in the file from the beginning?
<Stapler>
mrvn_: Note...I'm an OCaml newbie. Formerly used to C and Ada.
<mrvn_>
no. I think that opens the file so you can read from it.
<mrvn_>
Imagine it would be a 12 TB big file and you would open it.
<Stapler>
Ahhh...I see.
<Stapler>
So I need two functions/procedures. One for creating a "handle" and another to actually read from the handle.
<Stapler>
I'm checking to see if EOF is defined in the standard libs.
<whee>
no, it isn't
<whee>
you'll get an End_of_file exception raised if you hit eof while reading
<Stapler>
whee: I can't just define EOF myself and avoid the exception altogether?
<whee>
there's no way to read eof
<whee>
by definition eof means there's nothing left to read, the proper thing is to raise an exception
<Stapler>
whee: Well, your correct in that eof means theres nothing left to read. Not sure I agree that the "proper" thing(in all cases) is to raise an exception.
<whee>
what would you do if not an exception?
<Stapler>
whee: I would only raise an exception if there is no other behavior explicitly defined for when the stream hits eof.
<whee>
you can define whatever behavior you want by catching the exception
<whee>
and dealing with it
<whee>
the reading function really has no idea what to do when there's nothing left, so it raises and hopes someone else knows
<Stapler>
whee: True. But, if I was writing a time-sensitive app, I might not want to use an exception.
matkor has joined #ocaml
<matkor>
Good evening.
<whee>
they really aren't that much of a performance hit
<whee>
how often do you hit eof?
<Stapler>
whee: Of course, I'm assuming that exceptions are raised similiarly to Ada, which could be wrong.
<whee>
they're likely compiled down to a setjmp/longjmp much like C
<mrvn_>
How do I load ocamlp4 into a ocaml shell?
<Stapler>
whee: What if I knew the size of the file before hand, and just declared a char list 1..size_of_file?
<whee>
mrvn: #load "camlp4o.cma";; for normal syntax, camlp4r.cma for regular
<whee>
Stapler: you wouldn't hit eof then
<whee>
since you would know the size of the file, you wouldn't attempt to read past it
<mrvn_>
#load "camlp4o.cma";;
<mrvn_>
open Genlex;;
<mrvn_>
let lexer = make_lexer [" ";";";",";"."];;
<mrvn_>
let rec parse = parser
<mrvn_>
[< 'Kwd x; >] -> ()
<mrvn_>
| [< 'String x; >] -> print_string x
<mrvn_>
| [< n1 = parse; n2 = parse >] -> ();;
<Stapler>
Heh. Makes it nice and spiffy.
<mrvn_>
That should do what you want.
<whee>
exceptions are cleaner for things like that, anyway :p