<Defcon7>
how i can use to make a list from a string ?
<ayrnieu>
Do you mean to ask how you can construct a list of characters from a string?
<Defcon7>
a 'list', this type exists in ocaml
<Defcon7>
i wish to manipulate a string with the commands avaiable to manipulate lists
<Defcon7>
in list module
<Riastradh>
Defcon7, he's not asking what a list is. He's asking more precisely what you mean; he's asking if what you mean to ask is how to convert the string "foo" into the list ['f';'o';'o'].
<Defcon7>
so i think that i have to convert that
<ayrnieu>
Then you want to construct a list from the characters of a string.
<Maddas>
Defcon7: O'Caml's basic examples come with an example of how to do that
<Maddas>
(it's pretty easy)
mimosa has quit ["I like core dumps"]
malc has joined #ocaml
simon- is now known as _-simon-_
_-simon-_ is now known as simon
simon is now known as simon-
noss has left #ocaml []
simon- is now known as _-simon-_
_-simon-_ is now known as simon-
malc has quit ["no reason"]
gim has quit ["Zz."]
<Defcon7>
the "if" syntax if ((a=b) and (b=c)) or ((x>y) and (e<k)) is right ?
<Defcon7>
or we have to use && and ||
<Defcon7>
?
<Defcon7>
or the embracing is wrong ?
<Smerdyakov>
&& and ||
<Defcon7>
tnx :)
<Smerdyakov>
You could have just tried it. :D
<Defcon7>
you are right :)
<Defcon7>
try (List.nth 4 lastlist) with Failure -> ""
<Defcon7>
this gives an error: This expression has type int but is here used with type 'a list
<Defcon7>
but how i can handle List.nth exception without try ?
<Smerdyakov>
Look at the type of List.nth.
<Defcon7>
'try'
<Riastradh>
Defcon7, what is the type of List.nth?
* Riastradh
bahs at Smerdyakov!
<Defcon7>
val nth : 'a list -> int -> 'a
<Defcon7>
Return the n-th element of the given list. The first element (head of the list) is at position 0. Raise Failure "nth" if the list is too short.
<Riastradh>
What arguments have you passed to it, and what are their types, in oroder?
<Riastradh>
Order, even.
<Defcon7>
int ,list of strings
<Defcon7>
(4,lastlist)
<simon->
after reading some tutorials, I find O'Caml less confusing, but I still think there is a lot of stuff I find very crammed into the syntax
<Defcon7>
ops
<Defcon7>
i have inverted them
<Smerdyakov>
simon-, like?
<Defcon7>
sorry :P
<simon->
Smerdyakov, like named arguments (just to mention what I studied last)
<Riastradh>
Yes. OCaml's syntax sucks.
<Smerdyakov>
simon-, I hate those. :)
<Riastradh>
And though I think named arguments can be nice, OCaml's graft of them onto its syntax and onto currying is horrible.
<simon->
I actually like it. I just think there is a lot of stuff I could live without.
<Riastradh>
It would be so much easier if OCaml just used S-expressions.
<ayrnieu>
Riastradh - why do you see them as horrible?
<Riastradh>
Or I could just use Scheme and be happy.
<simon->
Riastradh, what are S-expressions?
<Riastradh>
ayrnieu, just think about how currying interacts with named and unpositional arguments.
<ayrnieu>
Riastradh - well, I think an s-expression syntax with camlp4 exists.
<Riastradh>
simon-, Lisp's syntax, in short.
<Defcon7>
this is my second day that i play with ocaml and i found it really cool, you'll love it :)
Kinners has joined #ocaml
<ayrnieu>
Riastradh - I suppose that I miss something, then, because I don't see anything horrible.
<simon->
well, I am really amazed how making recursive functions both looks and works pretty smoothly.
<Riastradh>
ayrnieu, you don't think that it's rather kludgily hacked on top of currying?
<ayrnieu>
simon - as opposed to making them in what other languages?
<simon->
ayrnieu, any imperative language. C?
<ayrnieu>
Riastradh - I don't see it as any kludgier than Haskell's system.
<ayrnieu>
simon - some people like to think of O'Caml as an imperative language =)
<Riastradh>
So I don't see what the comparison is.
<ayrnieu>
Riastradh - then I guess that I don't understand your complaint with O'Caml's named arguments, because O'Caml has and fails to have them in the same way.
<Riastradh>
??
<Riastradh>
You, um, _are_ familiar with OCaml's named arguments, or labels, right?
<ayrnieu>
Riastradh - can you provide some code, so we've something more solid to talk about?
<simon->
actually I think "class name = object (self) ... end;;" does not look very good either
<ayrnieu>
Riastradh - ah. Sorry, I read "named arguments" as "non-pointless"
<ayrnieu>
You should've said 'keyword arguments' =)
<Riastradh>
OK, yes, I ought to have, but simon- referred to them as 'named arguments' and my brain got stuck on that term momentarily.
* Riastradh
glares at simon-.
<simon->
sorry, one moment
<Defcon7>
http://www.nectarine.info/misc/prova.ml <- this is something like a simple log parser, can you like at it and tell me where i could be more coincise ?
<Defcon7>
more coincise or less stupid :P
<Riastradh>
You duplicate a _lot_ of code there.
<Defcon7>
cooool
<Defcon7>
hehe
<ayrnieu>
also, parentheses annoy me.
<ayrnieu>
by which I mean: *your* *use* of parentheses annoys me.
<Defcon7>
you are referring to the begin...end thing ?
<ayrnieu>
No; the way you put open- and close- parentheses on their own lines.
<Defcon7>
oh
<Defcon7>
probably you are right
<Defcon7>
lemme try
<ayrnieu>
but anyway, you should probably factor out a function with two arguments for the big if || && && && then expression.
<ayrnieu>
Yes, that function-factoring thing than needs to happen. Also, YOU MOCK ME
<Kinners>
Defcon7: you could make a function which takes two arguments (the string to build the regexp and the List.nth number)
<ayrnieu>
o/~ somebody o/~ reads the scrollback. mmm?
<Defcon7>
mock ?
<whee>
personally, I'd try to turn that if statement into a nice fold_left
<whee>
and of course do some refactoring with additional function declarations
<Defcon7>
hmm trying :)
<Defcon7>
why it says that "tail" isnt a function ?
<Defcon7>
it isnt :?
<Kinners>
Defcon7: is your factored function defined outside of the tail function?
<Defcon7>
yes it is
<Defcon7>
i tried to define into it but probably im trying in the wrong way
<Defcon7>
at the end of tail definition at the last ) i made ); let rec factored_function_name.....
<Defcon7>
but it (probably obviously) says syntax error
<Defcon7>
so i tried to define out of tail
<Kinners>
let lastlist = ... in let f re idx = ... in if ((f "^.*courier*" 4) || ...
<Defcon7>
hrm
<Defcon7>
how i can define it at the end of tail ?
<Defcon7>
which is the syntax ?
<Defcon7>
starting from the last )
<Kinners>
like, let rec foo x y z = (... ) and bar x y z = ... ?
<Defcon7>
hrm nop
<Defcon7>
); in
<Defcon7>
let rec getel lastlist n = try (List.nth lastlist n) with nth -> (tail chid) 0;;
<Defcon7>
where ) is the actual end of tail definition
<Defcon7>
but its wrong, so im asking what is the syntax to declare a function in that point
<Kinners>
just what I showed you, using 'and' instead of '; in let rec'
<Defcon7>
oh :)
<Defcon7>
sorry i didnt get you before
<Defcon7>
again it says that tail is not a function
<Defcon7>
(grrr)
<Defcon7>
why not, it is
<Defcon7>
plus it applies tail many times before
<Defcon7>
why not here
<Defcon7>
why here is not a function
<Defcon7>
O_o
<Defcon7>
im perplessed
<Smerdyakov>
Riastradh, at least you agree Defcon7 can't spell? ;)
<Kinners>
Defcon7: put it up on your site
<Defcon7>
Smerdyakov, try you to talk italian :P
<Defcon7>
Kinners done
<Riastradh>
Yes, I agree with that.
<Defcon7>
:P
<Riastradh>
Defcon7, for context, Smerdyakov wrongfully accused me of misspelling 'minuscule' in another channel, and now he's trying to make his mistake less drastic.
<ayrnieu>
(I consider those my friends that, however ineptly they speak English, speak it without vile hyperreductionism or k3wlt0k)
<Defcon7>
Riastradh loool
<Defcon7>
mumble mumble
Etaoin has joined #ocaml
<Etaoin>
hi
<simon->
hello
<Defcon7>
hi :)
<Etaoin>
neat
<Etaoin>
I expected no reply for a while
<Defcon7>
you will get it later dont worry
<Defcon7>
lool :P
clog has joined #ocaml
<Defcon7>
what about "tail is not a function" thing ?
<Defcon7>
anyone has discovered something ?
<Etaoin>
?
<Etaoin>
do camels have tails?
<Defcon7>
hehe
<Kinners>
Defcon7: you are doing (tail chid) 0 , which is using the result of 'tail chid' as a function and passing 0 to it
<Defcon7>
ouch hehe
<Defcon7>
what i wish to mean is to call tail chid, not to use it, what is the syntax :?
<Defcon7>
(not to use its result)
<Kinners>
just 'tail chid'
<Kinners>
(tail chid) 0 is like, let f = tail chid in f 0;;
<Smerdyakov>
Who wants to be my little tail chid?
<Smerdyakov>
My itty bitty cutey wutey tail chid?
<Defcon7>
hahaha
* Defcon7
get me, im your tail chid
<Smerdyakov>
OK. You're my tail chid.
<Defcon7>
hehe
<Defcon7>
kinners it works finally :)
<Defcon7>
thanks :D
<ayrnieu>
etaoin - yes.
<Etaoin>
ayrnieu: oh
<ayrnieu>
Etaoin - but why do you ask?
clog has joined #ocaml
<Defcon7>
there is any reason because a line like a := 2; cant be followed by a let ?
<Smerdyakov>
No reason.
<Defcon7>
im getting a syntax error in this situation
<Defcon7>
parentheses are probably right and the error is another
<Defcon7>
but is half hour that im searching it
<Defcon7>
if someone more skilled than me can take a look pls
<async_>
still having problems with that?
async_ is now known as async
<Defcon7>
hehe it has grow :)
<Defcon7>
i found the error
<async>
Defcon7: what was it
<Defcon7>
nope not found
async has quit ["Lost terminal"]
<Defcon7>
someone can help me ^?
<Defcon7>
hmm too late here
<Defcon7>
good night all
karryall has quit ["leaving"]
__buggs is now known as buggs
srv has joined #ocaml
mimosa has joined #ocaml
gim has joined #ocaml
mattam_ has joined #ocaml
mattam has quit [Read error: 60 (Operation timed out)]
maihem has quit ["Client exiting"]
Herrchen has joined #ocaml
<Herrchen>
hello
<Herrchen>
someone able to tell me, why "let f : 'a -> 'b = fun x -> x;;" doesn't produce a type error and makes 'a = 'b? Just thought this would cause some error, so I would see if I make mistakes, using a module type and defining the type of the value as above there produces an error message
<mattam_>
'a and 'b are unifiable, there's no reason the typechecking to error
mattam_ is now known as mattam
<Herrchen>
hmm no way to tell him not to unify?
<Herrchen>
because I explicitly using different names to express, they could be different
<mattam>
i don't think so
<Herrchen>
though defining it in a module type will produce an error, so the type checking is done there differently
<mattam>
hmmm, then you shouldn't rely on that, if it's not the same behavior in modules and regular code then it is probably implementation-specific
<mattam>
although i would find that pretty weird
<Herrchen>
well I thought maybe some error, but at least 3.06 and 3.07p2 behave like this
<mattam>
i get no error defining:
<mattam>
module SomeModule = struct
<mattam>
let g : 'a -> 'b = fun x -> x
<mattam>
end
<mattam>
module SomeModule = struct
<mattam>
let g : 'a -> 'b = fun x -> x
<mattam>
end
<mattam>
oops
<Herrchen>
hmm on toplevel I get no error with "let f : 'a -> 'b = fun x -> x;;"
<Herrchen>
ah
<Herrchen>
damn can't read
<Herrchen>
so we agree at this
<mattam>
that there is no error in any case ?
<Herrchen>
module F : sig val f : 'a -> 'b end = struct let f x = x end;;
<Herrchen>
produces an error
<Herrchen>
telling me 'a -> 'a and 'a -> 'b are incompatible as expected
<Herrchen>
I of course want to use the type declarations as some error catching, so the above no error stuff is very annoying
<mattam>
go to sig everything so ?
<Herrchen>
yes, but not that charming, don't want to write signatures when I export anyshit
<Herrchen>
but seems so as I have to
<Herrchen>
hmm well at least using camlp4 I could make this automatically
<mattam>
write code and use ocamlc -i to produce signatures when finished ?
<Herrchen>
oh I like it to have some "unmatched type at line xx error message"
<Herrchen>
so I thought of this
<Herrchen>
well I just try if there is much overhead if I put everything in modules
<Herrchen>
if not -> camlp4 and fun
<Herrchen>
well anyway I could use this way of compiling just for testing purposes
<Herrchen>
just a minor overhead in code-output and no performance loss as expected, well I try it this way no - thanks for info/help/suggestions/etc.
smkl has quit [zelazny.freenode.net irc.freenode.net]
smkl has joined #ocaml
owll has joined #ocaml
owll has quit [Client Quit]
<Herrchen>
bye
__DL__ has joined #ocaml
mimosa has quit ["I like core dumps"]
buggs|afk has joined #ocaml
rox is now known as rox|off
buggs has quit [Read error: 60 (Operation timed out)]
Demitar has joined #ocaml
<Defcon7>
http://www.nectarine.info/misc/prova.ml <- can someone take a look at this small ocaml program and tell me whats the error? (im getting syntax error in line 22, i tried for hours but no way to resolve it :| )