<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
<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..
<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?