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/
<holo> mikeX, i want to find out if some token composed only by number is an int, if it is, it converts it to float
<holo> using int_to_float
<holo> zmdkrbou, i don't understand your solution :s
<mikeX> a token? as in a lexer token?
<holo> mikeX, yes
<mikeX> I see, I'm not really familiar with that part of ocaml yet :/
<holo> and i have another doupt: i have to recognize expressions in a prefix notation: like < 5 4, should i recognize every element of that expression or just as a EXPR token for every expression that has that kind of padran?
<mikeX> if the token is a string however, I guess you could transform it to float and then to int
<holo> mikeX, lol, i know how.. if it tries to convert a number that is float to float, it gives some error
<holo> and doesn't convert
<mikeX> you could also 'try int_of_string s with Invalid_argument -> float_of_string s'
<holo> its ugly but i think it works
<holo> hehe, yeah it outputs an error
<mikeX> yes, since floats and ints are different types
<mikeX> (and my syntax is not 100% correct)
<holo> mikeX, what do you think of my question?
<holo> "and i have another doupt: i have to recognize expressions in a prefix notation: like < 5 4, should i recognize every element of that expression or just as a EXPR token for every expression that has that kind of padran?"
<holo> i need to send that to a parser
<mikeX> I'm not too experencied with lexer/parsers, but I guess you should have a rule that recognizes the whole expression, as e.g expr := less_operator int_num int_num
<holo> grr i'm stuck with such a simple thing
<holo> mikeX, so you aren't recognizing the whole expression
<holo> if it was a whole it would be expr:= Expr
<mikeX> well that would be part of some other rule
<mikeX> i'm sorry i don't remember much about parsers
Oeje1 has left #ocaml []
<holo> OpBin ::= "+" | "-" | "*" | "/" | "=" | "^" | ">" | "<" | "|" | "&"
<holo> OpUn ::= "sim"
<holo> that's the BNF specification of the grammar
joshcryer has quit [Client Quit]
<holo> "," is an operator?
<holo> mikeX, its fine. i'm very gratefull for your time!
<holo> we say "," as "produto cartesiano"
<holo> how do you say it in english?
<holo> can we face "produto cartesiano" as an operator?
revision17_ is now known as Revision17
<mikeX> cartesian product?
<holo> that
<holo> how do we say "[" ?
<holo> i'm assuming that every operator that isn't in the specification, isn't to be recognized as token
<holo> like <> or <= or => or ,
<holo> am i assuming too much?
<Smerdyakov> What are you talking about?
<holo> Smerdyakov, BNF specification of a grammar
<Smerdyakov> holo, your question still does not make sense to someone who doesn't have access to your thoughts.
<holo> Smerdyakov, this is presented to you as it was presented to me
<Smerdyakov> holo, the presentation to you contained the text 'how do we say "[" ?'?
<holo> i have to recognize tokens according to a BNF spec
<holo> lol
<holo> no
<Smerdyakov> That line does not make sense.
<holo> i want to know how to say "[" in english
<Smerdyakov> What does it mean "to say"?
<holo> Smerdyakov, in english....
<dylan> [ is left (square) bracket.
<holo> ha!
<holo> thank you dylan
<dylan> ] is right square bracket. There are other names, but those are what I use. :)
<holo> dylan, is there a more compressed way of saying it?
<dylan> bracket. :)
<holo> and "(" ?
<holo> is a bracket?
<dylan> "(" is a parenthesis.
<holo> haa
<holo> yeah
<dylan> opening parenthesis.
<Smerdyakov> () parentheses, [] brackets, {} braces
<holo> cool
<dylan> <> sometimes "angle brackets", but mostly by XML people.
<holo> hehe
<dylan> the esoteric language INTERCAL has some rather more colorful names for such symbols.
ellisonch has quit ["Leaving"]
joshcryer has joined #ocaml
holo has quit ["This computer has gone to sleep"]
joshcryer has quit [Read error: 104 (Connection reset by peer)]
joshcryer has joined #ocaml
mikeX has quit ["zzz"]
dylan is now known as Dylan[sleep]
<shrimpx_> so all of inria.fr is down or something?
Skal has joined #ocaml
Demitar has quit [Read error: 110 (Connection timed out)]
Smerdyakov has quit ["Leaving"]
Demitar has joined #ocaml
bluestorm has joined #ocaml
altDanly has joined #ocaml
danly has quit [Read error: 110 (Connection timed out)]
ertai has joined #ocaml
lakcaj has joined #ocaml
ertai has quit [Read error: 104 (Connection reset by peer)]
ertai has joined #ocaml
ertai has quit [Read error: 104 (Connection reset by peer)]
ertai has joined #ocaml
pauldia has joined #ocaml
Banana has quit ["Reconnecting"]
Banana_ has joined #ocaml
Banana_ is now known as Banana
love-pingoo has joined #ocaml
pauldia has quit [Read error: 110 (Connection timed out)]
ski has joined #ocaml
holo has joined #ocaml
Revision17 has quit [Read error: 110 (Connection timed out)]
joshcryer has quit [Client Quit]
Tachyon76 has joined #ocaml
Schmurtz has quit ["Plouf !"]
Tachyon76 has quit ["Leaving"]
coumbes has joined #ocaml
pango is now known as pangoafk
coumbes has quit ["Leaving"]
bluestorm has quit [Remote closed the connection]
pangoafk is now known as pango
mrsolo__ has quit [Read error: 104 (Connection reset by peer)]
mrsolo__ has joined #ocaml
holo has quit ["This computer has gone to sleep"]
Tachyon76 has joined #ocaml
mikeX has joined #ocaml
pauldia has joined #ocaml
bzzbzz has quit ["leaving"]
mikeX has quit ["bbl"]
Schmurtz has joined #ocaml
love-pingoo has quit ["Leaving"]
_fab has joined #ocaml
holo has joined #ocaml
<holo> hi
Smerdyakov has joined #ocaml
<holo> is there a function that returns true or false if an input string is a valid number?
<pango> try ignore(int_of_string s); true with Failure "int_of_string" -> false
Revision17 has joined #ocaml
<pango> try Scanf.sscanf s "%d" (fun x -> true) with Scanf.Scan_failure _ -> false
Tachyon76 has quit ["Leaving"]
<Smerdyakov> If those are the only alternatives, then I'd say it's cleaner to write your own.
<holo> lol
<Smerdyakov> In SML, ignoring overflow issues and assuming you mean to detect integers only, the function would be CharVector.all Char.isDigit.
<Smerdyakov> I don't know about OCaml.
<Smerdyakov> Actually, I guess that would be nonnegative integers only.
<pango> right
<pango> Str.string_match (Str.regexp "[0-9]+") s 0
<Smerdyakov> Much nastier.
<pango> ;)
Oejet has joined #ocaml
<Smerdyakov> One fish-slap-to-the-face for the OCaml standard library
<pango> well, it seems rather minimalistic... Maybe to give students something to write ;)
<pango> I don't really mind, string_for_all or char_is_digit aren't difficult to write, what bothers me more is badly designed APIs (like Str one that's both confusing and not thread safe)
<flux__> String.fold_left (fun ok i -> ok && i >= '0' && i <= '9') true s - if there was such a function
<Smerdyakov> I think iterators over strings are fundamental things to provide that may be significantly less efficient with any "user-space" implementation.
<flux__> Str's interface has actually bit me once
<flux__> that is: on the surface obviously correct code failed in a seemingly mysterious way
<pango> Smerdyakov: all but very basic operations on strings are implemented in "user space" already
cricket has joined #ocaml
<cricket> how could i go about converting a character from upper to lowr case?
<cricket> without wriring a function which handles a case for every letter in the alphabet
<flux__> look at module Char
<pango> cricket: it's in Char module already
<pango> cricket: but you can also use char ranges match c with 'A' .. 'Z' -> ...
<pango> you'll still need Char module however ;)
<Smerdyakov> pango, will OCaml's optimizer remove bounds checks for string accesses? If not, then it's fundamentally necessary to have special implementations of string iterators.
<cricket> where can i get info on the Char module?
<Smerdyakov> cricket, do you know where the OCaml manual is?
<cricket> no, im using NJSml btw
<cricket> does that matter
<pango> Smerdyakov: String.unsafe_[gs]et ;)
<Smerdyakov> cricket, yes. You have asked in the wrong channel.
<Smerdyakov> cricket, this is OCaml.
<Smerdyakov> cricket, it seems that you have developed an incorrect theory that people in #sml will not answer questions promptly. I encourage you to present me with any evidence that you think you have of that.
holo has quit ["This computer has gone to sleep"]
smimou has joined #ocaml
shawn has quit ["This computer has gone to sleep"]
love-pingoo has joined #ocaml
shawn has joined #ocaml
Snark has joined #ocaml
_JusSx_ has joined #ocaml
gim_ has joined #ocaml
cricket has quit ["BitchX-1.1-final -- just do it."]
shawn has quit [Connection timed out]
gim_ has quit ["piouf"]
shawn has joined #ocaml
<mattam> Smerdyakov: -unsafe option to the compiler
<mattam> s/to/of/
<pango> mattam: String.unsafe_get and String.unsafe_set where you _know_ bounds are already met
<pango> mattam: they're also reports of -unsafe actually slowing down programs ;)
<flux__> pango, hm, how come?-o
<flux__> anyway, I would hardly call removing redundant bounds checking 'fundamentally necessary', rather a nice optimization
<flux__> because ocaml can't inline functions across modules, it will not be able to remove the redundant bounds checking either..
<mattam> i know
<mattam> cache issues
<flux__> yahoo wants to feed me cookies to simply view that message, hmph
<pango> flux__: and create an account to reply :/
<flux__> well that's more bearable, I guess it keeps the level of spam sane
<pango> a yahoo account I mean; not just register to the mailing list
<mattam> flux__: it can inline across modules
<pango> (at least, afaik)
<flux__> mattam, if you compile them simultaneously?
<flux__> but surely not via .cmo/.cma/.cmx/.cmxa-files-o
<flux__> s/-o/?-o/
<mattam> for cmx yes
<flux__> hmm
<flux__> hmm.. so when it inlines, could it possible optimize redundant checks away?
<mattam> you mean the checks you wrote ?
<flux__> well, for example
<flux__> I guess there shouldn't be much difference between those and with the ones in the standard library
<mattam> that is way more difficult
<flux__> it only says 'it will inline its body', so body refers to the original code or the assembler?
<mattam> it would require an analysis
<flux__> actually my quote was bad, but: The body of an inlinable function is stored in the .cmx file for its defining module, thus it can be inlined from other modules.
<flux__> sure it would
<flux__> but isn't such analysis the promise of functional programming?-)
<mattam> well, in my opinion you should write in a programming language that forces you to check only when necessary
<mattam> but that's quite a challenge to get such a thing working and be usable
<flux__> gcc can do some pretty impressive optimizations, though
Skal has quit [Remote closed the connection]
cricket has joined #ocaml
<cricket> what does the syntax error: inserting VAL mean??
<ski> it assumes some value was accidentally left, so it, for the sake of giving more possible errors at same time, continues as if you had putten a value at this point ..
<cricket> i c
cricket has quit [Client Quit]
Revision17 has quit ["Ex-Chat"]
<_JusSx_> what's the name of compose function in ocaml?
<love-pingoo> you mean (fun f g x -> f (g x)) ?
Demitar has quit ["Ex-Chat"]
<_JusSx_> love-pingoo: yeah
Dylan[sleep] is now known as dylan
<love-pingoo> well I don't know any name for that
<_JusSx_> what's the name for ignore function? ignore: (a' -> b') -> unit
<love-pingoo> ignore
<love-pingoo> sorry
<pango> actually ignore sig is 'a -> unit
<love-pingoo> ignore is 'a -> unit
<_JusSx_> ah ok
<dylan> My fingers seem to think ocaml should have an ingore function...
_fab has left #ocaml []
* love-pingoo never realized List.make didn't exist
holo has joined #ocaml
<love-pingoo> on one hand it means it's not SO much needed, on the other hand it kind of sucks :(
<pango> love-pingoo: what would it do ?
<love-pingoo> just like Array.make
<dylan> let make n x = Array.to_list (Array.make n x)
<zmdkrbou> :)
<pango> love-pingoo: create a list in n identical values ?
altDanly is now known as danly
<mattam> people have repeat and so on i guess (i do)
<mattam> for compose it's not defined in the standard library
<mattam> but you can have 'let ($) f g = fun x -> f (g x)' and use it like in haskell
slipstream-- has joined #ocaml
mikeX has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
_JusSx_ has quit ["leaving"]
ski_ has joined #ocaml
ski has quit [Nick collision from services.]
ski_ is now known as ski
holo has quit ["This computer has gone to sleep"]
love-pingoo has quit ["Connection reset by by pear"]
Snark has quit ["Leaving"]
shawn has quit [Connection timed out]
pauldia has quit [Read error: 110 (Connection timed out)]
shawn has joined #ocaml
Submarine has joined #ocaml
vinceviper has joined #ocaml
chimikal_ has quit [Read error: 113 (No route to host)]
holo has joined #ocaml
<holo> hi
<holo> can i paste ugly code?
<holo> i'm even embarassed of doing such an ugly code
<zmdkrbou> if it's too big you can use pastebin.com or things like that
<zmdkrbou> (and it won't be in the logs :p)
<dylan> is there an ocaml library for i18n?
<holo> before that i must correct some things
<holo> :s
chimikal has joined #ocaml
smimou has quit ["bli"]
<holo> how do one force exit of all nested functions?
<zmdkrbou> with an exception
<holo> ok, what is the std exception argument to return a number?
<holo> like raise(Failure "string") but for integer
<pango> create your own
<holo> hu
<holo> ok ok
<pango> exception MyOwnException of int
<mikeX> holo: use http://www.pastebin.be , it has syntax hilight for ocaml :)
<holo> pango, i know how to do it, i was just admired there wasn't a default
<holo> :)
<pango> holo: even if there was, better create your own (and with a more meaningful name than my example
<dylan> camomile doesn't seem to have a debian package. :(
<pango> holo: Failure would be a bad way to carry string too, because many functions in standard lib can raise it
<pango> dylan: only in testing it seems
<mikeX> dylan: there'are 2 packages in sid, libcamomile-ocaml-{data|dev}
<dylan> hmm...
<dylan> ah, I see it.
<dylan> hmm, camomile seems a bit more complicated than gettext.