<idiotequa>
So does anyone know anything about Ocaml Lex and Yak?
<ita>
idiotequa: ask your question
<idiotequa>
Back
<idiotequa>
sorry
<idiotequa>
Well I guess people are familiar
<idiotequa>
I'm new to this room so I was wanting to get a general sense of the knowledge of Ocaml
<idiotequa>
since I'm a beginner to this as well as functional programming
<ita>
idiotequa: if you need an example of ocamllex/ocamlyacc use, i have one -> http://freehackers.org/~tnagy/eqchem-0.5.0.tar.bz2 (look in the subdirectory, there is a parser for chemical equations)
<mikeX>
idiotequa: there's a tutorial available for both ocamllex and ocamlyacc
<idiotequa>
Okay thanks guys
<mikeX>
google them
<idiotequa>
Yeah I have a program to do for homework and it involves changing up the Calculator program they have on the site
<idiotequa>
I have you create a "validity test" and put in boolean functions
<idiotequa>
have to *
<ita>
idiotequa: when you have some work to do, just do it
<idiotequa>
oh I know
<idiotequa>
I'm not asking anyone to code anything for me
<idiotequa>
sorry if it came across that way
<dbueno_>
idiotequa: Boolean functions in a calculator? You mean pseudoboolean?
<idiotequa>
possibly
<dbueno_>
I'm just wondering how the boolean functions interact with arithmetic expressions.
<dbueno_>
If they're pseudoboolean (0-1 valued), it makes sense.
mikeX has quit ["zzzZZ"]
<dbueno_>
1 + f(3)
ita has quit ["zzz"]
<dbueno_>
Could simplify to 1 + true (doesn't make sense) or 1 + 1 (does).
<dbueno_>
I'm just splitting semantic hairs.
<idiotequa>
I think so
<idiotequa>
it's like...
<idiotequa>
P v Q -> -Q -> P
<idiotequa>
returns true
<dbueno_>
Oh, so a validity test.
<dbueno_>
... like you wrote above.
<dbueno_>
But how does this interact with the "Calculator"?
<idiotequa>
(P -> Q) & Q -> P
<idiotequa>
returns false
<idiotequa>
yeah a test
<idiotequa>
ropositions may contain the constants 0 and
<idiotequa>
1 (representing false and true), parentheses for grouping, single
<idiotequa>
uppercase letters as variables, and the following operators, listed
<idiotequa>
from lowest to highest precedence
<idiotequa>
ops are things like ==, ->, v, &, -p
pango_ has joined #ocaml
pango has quit [Remote closed the connection]
idiotequa has quit [Read error: 110 (Connection timed out)]
bohanlon has quit [Read error: 104 (Connection reset by peer)]
jewel has joined #ocaml
jdev has joined #ocaml
bohanlon has joined #ocaml
kilimanjaro has joined #ocaml
shawn has quit ["This computer has gone to sleep"]
ktne has joined #ocaml
bohanlon has quit [Client Quit]
bohanlon has joined #ocaml
shawn has joined #ocaml
punisher has joined #ocaml
punisher has quit []
<flux__>
hmm.. I think it could be useful, if patterns were first-class citizens. is there a language that does this? something like let matcher p v w = match v with \p x when x = w -> true else false in matcher (Str _) (Str "Hello") "Hello" would work then..
<ktne>
heya flux__
<ktne>
i don't really understand what you mean
<ktne>
you mean to have programmable match?
<ktne>
like to send the match context as a variable?
<ktne>
you can do that using a function
<flux__>
yes, but it's less convenient
<ktne>
a function that defines just the match and then use that with currying, or i'm wrong?
<ktne>
hmm, you can't define just the match
<ktne>
the thing is that i'm not exactly sure what you mean :)
<ktne>
but remember that you need type inference to work, so any addition to the language but support type inference
<ktne>
i'm not sure if first class patterns would support type inference
<flux__>
well, you could have functions like let str_of s = match s with Str x -> Some x | _ -> None let int_of s = match s with Int x -> Some x | _ -> None
<pango_>
flux__: I've heard compiling 'match'es is non trivial, as it does important test optimizations, so separate cases may lose some of then 'identity' in generated code
<pango_>
s/then/their/
<pango_>
flux__: btw, the question was asked in beginners list, found that yesterday
<flux__>
fun timing
<pango_>
flux__: (not something recent; I was doing a search on tail recursivity, and found that)
b00t has joined #ocaml
<flux__>
..and after those functions you could do let matcher f v w = match f v with Some x when x = w -> true | _ -> false, but passing and using multiple patterns that way becomes inconvenient, because you can't use 'match'
<pango_>
couldn't find theorical knowledge on the tail rec topic, but still interesting informations
<pango_>
like, tail recursive version of functions may be something like 15% slower than "naive" implementation on small cases
<flux__>
I suppose most of these tricks could be achieved with camlp4, but with extra syntax
<pango_>
with an inversion of trends "around 2^12 recursive function calls"
<pango_>
where tail rec version then can get much faster (and eventually non tail rec simply fails, obviously)
<pango_>
so converting to tail rec "for the sake of optimization" shouldn't be done blindly
dibblego has quit [Read error: 110 (Connection timed out)]
<mellum>
pango_: I don't see that. Why would tail recursion ever be slower?
<mellum>
Smerdyakov: because it's much much shorter
<mellum>
and easier to read
<Smerdyakov>
Not even close.
<Smerdyakov>
Compare:
<Smerdyakov>
printf "%d is %s!" x y;
<Smerdyakov>
print [d x, " is ", y, "!"]
<mellum>
Okay, now make the integer zero-filled to 3 digits.
<Smerdyakov>
print [d0 3 x, " is ", y, "!"]
<mellum>
No, this is just reinventing the wheel. Printf is just fine.
<Smerdyakov>
Printf is less desirable, because the arguments are separated from the descriptions of how to print them.
<Smerdyakov>
AND it needs special support from the language.
<mellum>
I still prefer it. Probably a matter of taste.
<mellum>
Oh, and it can easily be i18n'd, while yours cannot.
<Smerdyakov>
What is that?
<mellum>
Internationalization
<flux__>
mellum, if you refer to retrieving format strings from a database, I don't think so
<Smerdyakov>
Yeah. In OCaml, formats must be known at compile time.
<flux__>
there could be a function like format_of_string_with_template "%d%s%d" (find_string "FOO") which would solve that, but I'm not sure it would be any better than just using lists :)
<mellum>
Smerdyakov: Oh, right. That would thwart this.
<mellum>
Oh well, I don't care about i18n anyway :)
<Smerdyakov>
Format strings are essentially functions in a special programming language. Serializing and deserializing them is no easier/harder than doing the same for arbitrary lists in the style I gave.
<flux__>
(although I prefer printf too: less ",",","-stuff)
<Smerdyakov>
flux__, easy to solve with macros.
<flux__>
also I think I actually LIKE the values are elsewhere :)
<flux__>
hm, is there a language extension that would provide a similar mechanism, usable with your own stuff?
<Smerdyakov>
It's trivial to compile printf into it.
<flux__>
I suppose so, but I haven't done any camlp4-stuff :)
<flux__>
actually, if you scroll a few pages back, I have a related problem..
<Smerdyakov>
Sorry, I must go now.
<flux__>
I found the gettext-bindings for ocaml
<flux__>
the first function is:
<flux__>
let format_of_string x =
<flux__>
Obj.magic x
<flux__>
\o/
<flux__>
I suppose it might have a proof somewhere that it doesn't do anything wrong.. even though I somehow doubt it
<flux__>
actually, it could very well have that proof
smimou has joined #ocaml
postalchris has joined #ocaml
pango has quit ["Leaving"]
pango has joined #ocaml
vadimtk has quit [Read error: 110 (Connection timed out)]
shawn has quit ["This computer has gone to sleep"]
<seto>
I search people who uses vim for editing ocaml, I need an easy way to test my ocaml code in vim, to view debug, and to test line per line if it's possible, but don't find many documentation about that
<nattfodd>
I'm usually using a toplevel in another term with big #load "bli.cmo"
<nattfodd>
I did some of the interactive stuff with a lisp toplevel though
<nattfodd>
but it was complex to set up and not really practical
romildo has joined #ocaml
<romildo>
Hi.
<romildo>
How can I get the current directory as an absolute path, in a portable way?
<romildo>
I am asking because Filename.current_dir_name is "the conventional name for the current directory (e.g. . in Unix)", and that is not enough for me. I need the abolute path of the current directory.
<seto>
nattfodd: hmm ok, and about editing project and have a debugger ? you use the makeprg variable or something else ?
mikeX_ is now known as mikeX
<pango>
romildo: Unix.getcwd () ?
<romildo>
pango: Is it portable? My program is supposed to run at least on both Linux and Windows.
<seto>
nattfodd: sorry for my bad english.. (you don't speek french?), I only want to compile my file for ocaml, but for now I use :!ocaml < % , I think you know a better way so I ask it
<nattfodd>
seto: yes, I am french too, but this is an english chan...
<pango>
seto: ocaml is the toplevel interpreter
<nattfodd>
seto: ah, I always make a Makefile
<nattfodd>
and ocamlc
<pango>
seto: ocamlc and ocamlopt are the bytecode and native compilers, respectively
<seto>
nattfodd: I think it's the good way, do you have a short makefile for little plroject (like one file :D) .. I go search on the web if not
<pango>
btw $(OCAMLFLAGS) is used twice, I guess the second should be $(OCAMLOPTFLAGS)
<romildo>
pango: I need the absolute name of a file for use with GtkFileChooser (from lablgtk). I have just a relative name. So I need the current directory name to build its absolute name. glib has g_get_current_dir and g_build_filename. But it seems that they have not been considered in lablgtk. Any comments?
<nattfodd>
seto: out of curiosity, are you a student somewhere?
batdog|gone is now known as batdog
chessguy has joined #ocaml
<seto>
nattfodd: hmm, yeah, in m1 in poitiers.. are you a teacher in my university ;D ?
<nattfodd>
heh no :)
<nattfodd>
I'm in m2 in paris
<seto>
student too .. well
<nattfodd>
but I heard that the new l3 at the ens lyon were all using vim, so I wanted to check :)
<seto>
in my university .. only emacs, and some java ide .. so I am alone
<nattfodd>
try to convert people
<nattfodd>
it usually works pretty well, especially as (g)vim is so much better looking than emacs
<mellum>
Yeah, you'll be much more productive with a slick looking editor
<seto>
yeah.. but it's difficult, for now, in my 4 university years, I convert 20 people to use linux, and 5 to use debian.. but nobody follow me in vim
<nattfodd>
mellum: not to use, but it's a good argument to make people at least try