__DL__ changed the topic of #ocaml to: OCaml 3.09.0 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/
tom_p has quit [Read error: 104 (Connection reset by peer)]
tom_p has joined #ocaml
__DL__ has quit ["Bye Bye"]
malc_ has left #ocaml []
quamaretto has joined #ocaml
m3ga has joined #ocaml
Smerdyakov has quit ["Leaving"]
pango_ has joined #ocaml
knobo has quit [Remote closed the connection]
m3ga has quit ["disappearing into the sunset"]
knobo has joined #ocaml
pango has quit [Read error: 110 (Connection timed out)]
pmdboi has joined #ocaml
gim has quit [Read error: 110 (Connection timed out)]
descender has quit ["XML is like violence, if it doesn't solve the problem, just use more."]
m3ga has joined #ocaml
pmdboi has quit ["Leaving"]
m3ga has quit ["disappearing into the sunset"]
khermans has joined #ocaml
<khermans> anyone in here?
<khermans> or, up?
khermans has quit ["Leaving"]
<flux__> maybe
<flux__> oh, he isn't anymore
joshcryer has joined #ocaml
ksd has quit [Read error: 104 (Connection reset by peer)]
robajs has joined #ocaml
<robajs> hello
ski has quit [Read error: 110 (Connection timed out)]
Schmurtz has joined #ocaml
kryptt has joined #ocaml
malc_ has joined #ocaml
chs_ has quit []
seerhut has joined #ocaml
imperator has joined #ocaml
imperator has left #ocaml []
Schmurtz has quit ["Dodo !"]
Schmurtz has joined #ocaml
_JusSx_ has joined #ocaml
ski has joined #ocaml
robajs has quit [".."]
ski has quit [Read error: 110 (Connection timed out)]
seerhut has quit [Read error: 110 (Connection timed out)]
rillig has joined #ocaml
twobitsprite has quit [Nick collision from services.]
descender has joined #ocaml
twobitsprite has joined #ocaml
twobitsprite has quit [Nick collision from services.]
telemakh0s has joined #ocaml
Smerdyakov has joined #ocaml
Amorphous has quit [Remote closed the connection]
Amorphous has joined #ocaml
Smerdyakov has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
<jeremy_c> Does OCaml have such thing as uninitialized or null values ?
<_JusSx_> jeremy_c: no
tom_p has quit [Read error: 113 (No route to host)]
<smimou> jeremy_c: the usual trick is to use an option type if you really need something like that
Raziel has quit ["Yo soy goma. Tú eres cola."]
Raziel has joined #ocaml
pmdboi has joined #ocaml
<jeremy_c> smimou: I was thinking of it. You mean like type nullable = Nil | String of string etc ?
<pmdboi> i've kind of jumped in here, but would an option be good for that?
<pmdboi> like, string option
<jeremy_c> pmdboi: I am not familure with string option, I am still learning ocaml. I am using it for sql data access.
<pmdboi> option is just a built-in type constructor... the definition is just "type 'a option = None | Some of 'a"
<jeremy_c> pmdboi: hm. Sounds good. How do I get the string from it?
<pmdboi> it's used for what would be considered "nullable" types... like, there's no universal NULL in ocaml like there is in C++, so you can use that instead when you need it
<pmdboi> the "best" way is to use matching: if "so" is your string option, then do something like 'match so with Some s -> s | None -> raise Exception "String is null"'
<pmdboi> i think there are some built-in functions for extracting the data from an option, as well
<pmdboi> and that "Exception "String is null"" should be in parentheses... stupid precedence :)
<Smerdyakov> jeremy_c, it seems that you are trying to "learn" OCaml without reading about it.... aren't you following a tutorial that would have made the answer to that apparent?
<jeremy_c> Smerdyakov: you are partly correct. I have read the basics and then am working on a project and learning about problems when they arrise. I know it's not the best way. I should just finish the book I have.
<jeremy_c> I have the book Developing Applications with Objective Caml by OReilly
* dylan learned ocaml by doing, and the reading standard library.
<jeremy_c> copyright 2000
<pango_> jeremy_c: if you haven't read about sum types, you didn't read enough of the basics :)
<jeremy_c> dylan: yeah, I keep that up in my web browser.
<jeremy_c> pango_: I went through that whole section. It has a few tutorials using cards, King, Queen, etc... I didn't realize there was a built in option type though.
* jeremy_c was amazed at what could be done with them in such a short amount of code.
<jeremy_c> My question about getting the string from the string option was due to the fact that option was built in, I did not know if there were built in methods to access the value since the type was built in.
<dylan> I think using pattern matching is the normal way to access options.
<Smerdyakov> Option is not built-in.
<Smerdyakov> It's just in the standard library.
<jeremy_c> ok. bad wording...
<dylan> Smerdyakov: Thank you! You just gave me an idea on what to call core functions in my esoteric squirrel-based language! :)
<pmdboi> squirrels!
<dylan> built-in -> inbuilt -> inbred.
<dylan> you have user-defined squirrels and inbred squirrels. :)
<pmdboi> nice
<pango_> Smerdyakov: not so sure; it's commented out in pervasives.ml
<pango_> Smerdyakov: probably another hack ;)
<pango_> $ grep option pervasives.ml
<pango_> (* type 'a option = None | Some of 'a *)
<pmdboi> weird
<dylan> it has the same tag and size as it would, if it were defined in pervasives.
<pmdboi> how can you tell?
<dylan> Or Obj lies.
* pmdboi will have to poke around that module
<dylan> it appears identical to type 'it opt = Empty | Full of 'it ;;
rillig has quit ["exit(EXIT_SUCCESS)"]
<pango_> it's probably defined exactly that way, but in compiler (weak types both need option types, and some support from the garbage collector... that would be my guess)
<smimou> dylan: what does inbread mean? (never seen that word before)
<smimou> -a
<dylan> smimou: Well, it's what they do to horses, dogs, cats... It's when you breed two animals that are relatives together.
<pmdboi> it's not related to programming languages
<smimou> ok :)
<pmdboi> unless you're talking about the programming languages themselves :)
<dylan> it's related to squirrels, though.
<pmdboi> squirrels!
Raziel has quit ["Yo soy goma. Tú eres cola."]
Schmurtz has quit [Read error: 110 (Connection timed out)]
Raziel has joined #ocaml
Smerdyakov has quit ["Leaving"]
smimou has quit ["bli"]
smimou has joined #ocaml
descender has quit ["XML is like violence, if it doesn't solve the problem, just use more."]
mkhl has joined #ocaml
Smerdyakov has joined #ocaml
ski_ has joined #ocaml
quamaretto has quit [Remote closed the connection]
quamaretto has joined #ocaml
kryptt has quit [Read error: 110 (Connection timed out)]
Smerdyakov has quit ["Leaving"]
pmdboi has quit ["This computer has gone to sleep"]
cmeme has quit [Read error: 104 (Connection reset by peer)]
cmeme has joined #ocaml
mkhl has quit []
<jeremy_c> Just a fyi, the manual documents type 'a option = None | Some of 'a under the built-in types along with string, float, bool, etc...
* quamaretto makes Some(None) and puts it in a jar for later.
<jeremy_c> Anyone care to critique this function for learning purposes?
<jeremy_c> let rec strip str =
<jeremy_c> let last_idx = ((String.length str) - 1) in
<jeremy_c> match str.[last_idx] with
<jeremy_c> ' ' | '\t' | '\n' | '\r'-> strip (String.sub str 0 last_idx)
<jeremy_c> | _ -> str ;;
<malc_> jeremy_c: why not just accumulate interesting index, and then do one .sub call?
<jeremy_c> I would then have to pass the index around in the recursive function, correct?
<malc_> aye
<jeremy_c> I'm still trying to find a balance in making the function easy to use. If that were the case, so I could still call (strip "John "), I would want to create a wrapper function such as (_strip str idx) ... is that how you would do it?
<malc_> i would define an auxiliary function inside the strip
* jeremy_c goes to the manual to figure how how.
<jeremy_c> malc_: thanks. that does make sense.
<malc_> let strip s = let rec aux cur_index last_valid_char_index = ...
<malc_> np
Smerdyakov has joined #ocaml
<jeremy_c> malc_: hm. I tried that a bit earlier w/no luck. I don't understand how to end my aux function and start the content of my real function.
<jeremy_c> for instance: http://pastebin.com/485635
<jeremy_c> hm. nm, that actually worked, except I am taking 1 too many off the end.
quamaretto has quit ["Leaving"]
<jeremy_c> that has it, thanks for the tip malc_ !
_JusSx_ has quit ["leaving"]
mauke has quit [Remote closed the connection]
mauke has joined #ocaml
Smerdyakov has quit ["Leaving"]
<ski_> jeremy_c : i think you also need to handle the case when the string consists of only whitespace (or is the empty string)
<jeremy_c> ski_: ah. thanks. I didn't think of that and am sure the case will arise.
joshcryer has quit [Connection timed out]
gim has joined #ocaml
m3ga has joined #ocaml