From: ciol <ciol13@gmail.com>
To: caml-list@inria.fr
Subject: Functional programming using caml light
Date: Wed, 01 Nov 2006 13:12:12 +0100 [thread overview]
Message-ID: <eia2ut$l9o$1@sea.gmane.org> (raw)
Hello,
in this book ( http://caml.inria.fr/pub/docs/fpcl/index.html ), there is
the following grammar (chapter 10.3, on streams etc...) :
Expr ::= Mult
| Mult + Expr
| Mult - Expr
[...]
after factoring common prefixes, the author obtains :
Expr ::= Mult RestExpr
RestExpr ::= + Mult RestExpr
|- Mult RestEXpr
|(* nothing *)
[...]
But I don't obtain the same result for RestExpr :
RestExpr ::= + Mult Expr
|- Mult Expr
| (* nothing *)
Am I wrong ? (and why ?)
----------------------------------
Another question (totally different) :
I've created the type :
type expr = Plus of expr * expr
| Minus of expr * expr
| Div of expr * expr
| Sin of expr
| Cos of expr
[etc... (not important)]
when I match an expression, I do for instance :
Plus (u, v) -> blablabla (u, v)
Minus (u, v) -> blablabla (u, v) (same result as above)
Div (u, v) -> a different result
Can I reduce the code in order to do such a thing :
Div (u, v) -> blabliblou
BinaryFunction (u, v) -> blablabla (u, v)
(BinaryFunction match for both Plus and Minus (all the others binary
functions))
Thank you (maybe should I have written in french ?)
next reply other threads:[~2006-11-01 12:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-01 12:12 ciol [this message]
2006-11-01 12:42 ` ciol
2006-11-02 20:58 ` ciol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='eia2ut$l9o$1@sea.gmane.org' \
--to=ciol13@gmail.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox