<ketty>
the syntax is: let [declaration] and [declaration] in [expression]
<ketty>
you do: let [declaration] and let [declaration] in [expression]
<ketty>
which is wrong :)
<metaperl>
oh, thanks
<metaperl>
I'm getting a hard to grok type error (this expression has type lex_node -> bool but is here used with type bool) : http://ocaml.pastebin.com/725874
<metaperl>
any help is appreciated
<ketty>
metaperl: hmm...
<ketty>
what part of the line do the error refer to?
<ketty>
ahh..
<ketty>
the type of dic_elem_matches_char: char -> lex_node -> bool
<ketty>
you forget to give it a lex_node
<ketty>
so you get "lex_node -> bool" back
<ketty>
but you need "bool", thous the compiler gives you an error...
cyyoung has joined #ocaml
<metaperl>
ketty: I was trying to curry it
<metaperl>
oh the not needs a book
<ketty>
metaperl: i think you failed :)
<metaperl>
bool
<metaperl>
lol
<metaperl>
the idea is to get a lex_node. then create a curried version of dic_elem_matches_char. then call that and negate the result
<metaperl>
oh I think I should make it others = List.filter (function dic_elem -> (not (dic_elem_matches_char s dic_elem))) dict
<ketty>
yes, that should work
<ketty>
let compose f g = fun x -> f (g x);; List.filter (compose not dict_elem_matches_char) dict
<metaperl>
sweet
<metaperl>
I have a logic error of some sort in my Not_found branch... I have to sweat this one out
<metaperl>
i use XEmacs. the indentation in that mode is not working so well
<metaperl>
ketty: I put some test cases at the bottom of this lextree file... the last one is not working the way I want it to... would you mind looking at that one: http://ocaml.metaperl.com/ora-book/lextree.ml
<ketty>
metaperl: could you explain the problem in more detail?
<metaperl>
the goal
<metaperl>
is to insert a letter in the trie
<metaperl>
now you mean what is my problem?
<metaperl>
why am I not happy with my program?
<ketty>
yes, what fail to work?
<metaperl>
ok
<metaperl>
in the case were a new branch must be created in the tree
<metaperl>
it works fine when this branch must be done at the very start of the tree
<metaperl>
if you traverse down in to the tree and try to create a sibling branch
<metaperl>
instead of doing so
<metaperl>
it does insert it at the right place
<metaperl>
but instead of it being cons'ed onto the list of siblings
<metaperl>
the entire original tree is it's sibling
<ketty>
ok, i see
<metaperl>
I think the definition of dict that is being used outside the try is different from within
<metaperl>
you think so?
<ketty>
hmm.. maybe
<metaperl>
if you play with the test cases (especially the last one)... you will see what I mean
<metaperl>
oh I think I get it
khaladan has joined #ocaml
<metaperl>
the exception pops out to the topmost stack level
<metaperl>
where the original definition of dict lives
<metaperl>
did you play with it ketty?
<ketty>
which is weird...
<metaperl>
just type far;;
<metaperl>
and then type insert "fab" far;;
<metaperl>
and you will see that the whole tree is reproduced as the sibling of Letter('b', true, []);;
<ketty>
yes, i see what you mean..
<metaperl>
see what I mean
<metaperl>
:)
<metaperl>
super-werid
<metaperl>
that must be how exceptions work
<ketty>
it is not :)
<metaperl>
is there a mailing list I migh... never mind..I'll goto the ocaml website and ask
<metaperl>
ketty: are you a student?
<ketty>
yes
<metaperl>
ketty: what level?
<ketty>
first year at university
<metaperl>
you know a lot for first year at university
<metaperl>
you mean undergraduate?
<ketty>
thank you :)
<ketty>
what is undergraduate?
<metaperl>
well it is before graduate school
<ketty>
(i am swedish, so i am not familar with all such terms)
<metaperl>
and graduate school is where you get an M.S. and Ph.D
<metaperl>
aren't you in Germany?
<ketty>
no :)
<metaperl>
so what do you think is happening in this program?
<ketty>
i don't know.. maybe it is time to use the debugger?
<metaperl>
i wonder if the windows version has that
* metaperl
checks
<metaperl>
I have to go run it on my webserver
<ketty>
metaperl: the problem is this line: Letter(c, b, insert ss dict)::others
<metaperl>
ketty: you are saying the problem is not in the Not_found branch
<ketty>
yes
<ketty>
i am saying that :)
<metaperl>
ketty: I think you are right. I just tried insert "fa" far;; and it gave similar behavior
<metaperl>
oh yes, I see why you are right now
szloto has joined #ocaml
<metaperl>
yes, now it works.
<metaperl>
thank goodness
<ketty>
:)
<metaperl>
what does "ketty" mean?
<ketty>
hmm?
<ketty>
i don't think it means anything
<metaperl>
why did you choose that name?
<ketty>
it's kind of my given name :)
<metaperl>
oh... first name or last name?
<ketty>
first
<metaperl>
oh
<metaperl>
:)
<metaperl>
it's time for me to take a little nap
<ketty>
ok
sidewinder has quit [Read error: 110 (Connection timed out)]
cyyoung has quit ["Leaving"]
jcreigh has joined #ocaml
chessguy2 has joined #ocaml
chessguy2 has quit [Client Quit]
chessguy has quit [Connection timed out]
Smerdyakov has quit ["Leaving"]
jcreigh has quit ["Do androids dream of electric sheep?"]
dark_light has quit [Read error: 110 (Connection timed out)]
slipstream has joined #ocaml
slipstream-- has quit [Read error: 104 (Connection reset by peer)]
Skal has joined #ocaml
multani has quit ["Parti"]
love-pingoo has quit ["Connection reset by by pear"]
smimou has joined #ocaml
pango is now known as pangoafk
pangoafk is now known as pango
Tachyon76 has joined #ocaml
mikeX has joined #ocaml
girodt has joined #ocaml
<girodt>
hello
<girodt>
is there a way to access the nth element of a tuple, a bit like myarray.(x) ?
<flux__>
no
<smimou>
pattern matching
<flux__>
you can't write a function that would work with n-tuples, though
<flux__>
also note that all the elements must be of the same type, if you wish to index them by (ie.) a number
<flux__>
arrays and tuples are very different beasts :)
<girodt>
okay thanks
damg has joined #ocaml
reltuk has quit []
m3ga has joined #ocaml
gim__ has joined #ocaml
hikozaemon has quit ["Leaving..."]
m3ga has quit ["disappearing into the sunset"]
metaperl has quit [Read error: 104 (Connection reset by peer)]
metaperl has joined #ocaml
mikeX has quit ["leaving"]
<girodt>
Hi again. i have to call a method which is defined later in my code. I've heard there is a way of defining all my functions like in a header file ... anyone can give me a hint ?
<girodt>
is it the role of .mli files ?
<zmdkrbou>
yes
<zmdkrbou>
a .ml file is a module, and you put its signature in the corresponding .mli file
<zmdkrbou>
(it allows to hide some implementation details, which is cool)
<girodt>
yes
<girodt>
good, i'm doing it.
<girodt>
do i have to declare types and classes into it ?
<zmdkrbou>
yes, if you need to use them from outside
<metaperl>
is there not a let compose f g x = f (g x) ;; built into ocaml?
<flux__>
that is correct
dvorak_ has joined #ocaml
dvorak has quit [Read error: 110 (Connection timed out)]
Tachyon76 has quit ["Leaving"]
<girodt>
okay, i've got all my signatures copied in a file tom.mli. when i launch make, it says there is an error on the first line - but it's copy-pasted from the signatures written by the interpretor. did I miss something ? is there something to add or delete ? my first line is val verbose : bool ref = {contents = false}
<pango>
compile module with ocamlc -i or ocamlopt -i, to get signature to stdout
<girodt>
well, it can't compile because of cross references between many things ... so there is always something i should define before ...
<girodt>
when i do ocamlc -i it just says "Unbound type constructor neuron
<girodt>
"
<girodt>
that's why i'm copying it from the interpreter ...
<girodt>
okay i sorted it out ... so boring =_=
<girodt>
so when i have this .mli file, I can reorder my code without bothering about def precedence right ? am I supposed to pass the .mli file as an argument to ocamlc ?
<flux__>
hmm.. mli-files don't affect how the .ml-file is compiled
<flux__>
do even if you declare something in the .mli-file, it doesn't mean in the .ml-file you may refer to it
<flux__>
(before you've defined it in the .ml-file)
<flux__>
however, compiler does automatically refer to the compiled .cmi-file (ocamlc -c foo.mli -> foo.cmi)
<flux__>
and check that it adheres to the interface
<flux__>
and the paste you provided doesn't look like an .mli file to me
<flux__>
because you cannot have code in an .mli-file (including assignments)
<flux__>
right, as pango suggested, ocamlc -i will produce the output what you're looking for
<girodt>
ok.
<girodt>
so i have to generate the ouput, compile it to .cmi file, and then I can put my code in proper order right ?
<flux__>
I think the .mli/.cmi is of no use to you at this point
<flux__>
your original problem was that you needed to refer to method which wasn't defined at the point of use?
<girodt>
yes. it seems .cmi file is automatically generated anyway ...
<flux__>
yes
<girodt>
tes
<girodt>
yes
<girodt>
this is my problem
<flux__>
.cmi needs to exist so other .ml-files can be checked that they use the interface properly
<flux__>
well you can probably sitestep the issue by having a parent class that provides the methods but no code
<flux__>
that is, an interface that your actual class will implement
<flux__>
as there is no code there are no mutual dependencies
<girodt>
i see.
<girodt>
this is quite troublesome ...
<flux__>
well, my ocaml-oo isn't that solid, so maybe there is better advice around
<girodt>
actually, it does not seems to be specifically OO problem.
<girodt>
you can have pretty much the same with fully functional code.
<girodt>
say you want to define things clearly, and you explicitly write the type of each parameter to your functions. you will be very likely to refer something defined later ...
<flux__>
I personally haven't found that I have many mutual dependencies between functions, only 'backward ones', maybe because you can pass the dependency (function) as an argument
<pango>
girodt: declare your types simultaneously ?
<girodt>
hmm ... in fact you can probably always solve such a problem by rearanging the order of your functions, as types are defined before. but it can be quite troublesome when you are trying to keep your code tidy.
<girodt>
so i guess there comes the modules ...
<girodt>
but i'm not there yet
<girodt>
:)
Snark has joined #ocaml
kangabroo has joined #ocaml
<ketty>
girodt: you can declare mutal recursive functions or modules...
<girodt>
if you say so :)
<girodt>
i think it is beyond my scope :)
ramza3 has joined #ocaml
<pango>
let rec even x = x = 0 || odd (x - 1)
<pango>
and odd x = not (x = 0) && even (x - 1)
<pango>
magical word is "and"
<flux__>
and, as I referred earlier, this can be found to match most cases too:
<flux__>
let event ~odd x = x = 0 || odd (x - 1)
<flux__>
let rec odd x = not (x = 0) && event ~odd (x - 1)
<flux__>
and to finalize you can use let event x = event ~odd
<flux__>
also event -> even :-)
<flux__>
(what a consistent typo)
<flux__>
(I write that word a lot at work)
ramza3__ has quit [Connection timed out]
<pango>
that's your event horizon
<flux__>
I actually noticed it only after I was writing that finalizing statement
<flux__>
I wondered why did the event-version go through :)
smimou has quit ["bli"]
smimou has joined #ocaml
<girodt>
thanks again for your help today. bye
girodt has quit ["leaving"]
kangabroo has quit [Remote closed the connection]
finelemon has joined #ocaml
finelemo1 has quit [Read error: 110 (Connection timed out)]
sieni_ has joined #ocaml
sieni has quit [Read error: 104 (Connection reset by peer)]
finelemon has quit [Read error: 110 (Connection timed out)]
finelemon has joined #ocaml
khaladan has quit [Read error: 104 (Connection reset by peer)]
<metaperl>
how do I append a character to a string?
<ketty>
metaperl: you append strings together with ^
<pango>
Printf.sprintf "%s%c"
<metaperl>
"hello" ^ 'c' ;;
<ketty>
problem is 'c' is not a string :)
<metaperl>
ketty: I was saying that a character is not a string so ^ does not apply
<metaperl>
pango: thanks
<metaperl>
ketty: dont you have to go to class sometimes?
<ketty>
you can convert characters to strings...
<metaperl>
ketty: how?
<metaperl>
'c'::string ;;
<ketty>
String.make 'c'
<metaperl>
'c':string;;
<ketty>
String.make 1 'c'
<pango>
if you need to do such things very often, you should go for Buffer instead of String
<ketty>
maybe :)
<metaperl>
ah, I thik pangohas the simply approach
<ketty>
pango: i think the same applies to sprintf
<pango>
yes, I meant "such things" = "append chars and strings to the end of a string"
<ketty>
yes, i understand that now :)
<ketty>
metaperl: no, i had my last class yesterday...
<ketty>
now i only have assignments and exams left... :/
<metaperl>
oh I see
<metaperl>
are you a comp. sci major? I would think so
<ketty>
i would think so too :)
<avlondono>
hum
<avlondono>
how can I define a signature with a type that is a polymorphic variant that includes at least `A?
<pango>
I think it's [> `A ] but don't take my word for it
<avlondono>
that's what I thought
<avlondono>
but I can't get it going
<ketty>
avlondono: if you want it in a signature you mabe need to use private row types...
<avlondono>
yeah, but then apparently I can't construct anything, defeating the purpose of the polymorphic variants
<avlondono>
I'm missing something here ... :-(
<ketty>
i haven't used polymorphic varians much...
Smerdyakov has joined #ocaml
<ketty>
your best reference for usage is probably lablgtk2
dvorak_ has quit ["Reconnecting"]
dvorak has joined #ocaml
<avlondono>
I'll check that out. the thing is that I want functors where the parameter structures define polymorphic variant types
* Smerdyakov
spits on polymorphic variants!
<ketty>
to avlondono, maybe the paper: "Code reuse through polymorphic variants" is of interest?
<Smerdyakov>
avlondono, I haven't yet seen a convincing use for them, and they are much less statically checked than traditional ML features.
<metaperl>
pango: struggling is a more accurate term :)
<metaperl>
but I'm on my way
<pango>
metaperl: here too, there's a clever way to avoid catenating chars... Because you know the length of all result strings ;)
<pango>
metaperl: but that's an optimization
<metaperl>
pango: but you have to return all the selected words
<pango>
metaperl: yes
* ketty
envies metaperl and pango
<ketty>
i have to mess with java for an assignment :(
<metaperl>
ah, the pains of undergrad
<metaperl>
write an ocaml to java translator :)
<ketty>
:)
<metaperl>
ketty: is that for summer school. you said school ended
<ketty>
only my lessons ended
<ketty>
i still have assignments and exams
<avlondono>
Smerdyakov: that's true, for me it's practical, avoiding namespace clutter and circular dependencies
<Smerdyakov>
avlondono, do you have an example of the problem?
<avlondono>
yeah, but it would be too annoying to explain here
<Smerdyakov>
OK, but I'll refrain from believing that you have a good case without some explanation. :P
<avlondono>
Smerdyakov: I am also using them to make a parallel program type safe. the messages are unsafe and polymorphic variants let me check and group those messages in a natural way.
<avlondono>
of course you can't just believe me :-)
<Smerdyakov>
Without more explanation, I don't see how regular variants don't do that just as well.
<avlondono>
Smerdyakov: the problem with regular variants was that an illegal message would almost always cause a segfault
<Smerdyakov>
avlondono, that's a bug in your code.
<avlondono>
yes
<avlondono>
exactly
<Smerdyakov>
Then.... fix the bugs?
<avlondono>
with polymorphic variants I can catch them faster as I can grab the message and inspect it later.
<avlondono>
it's not theoretical, it's practical
<Smerdyakov>
You can check for validity on the C side and fail immediately if a bad message comes through.
<avlondono>
yeah, that I can do. Or what I'm doing with has far less effort.
<metaperl>
smimou: thanks for the link. I think this is going to work out for me
pango is now known as pangoafk
Revision17 has quit [Read error: 110 (Connection timed out)]
pangoafk is now known as pango
_jol_ has quit ["Changing server"]
_jol_ has joined #ocaml
_jol_ has quit ["Changing server"]
<metaperl>
pango: that subselect in select_v1 is profound: it is saying the items of length n have length n -1 in the children... so find the items of length n - 1 in the children