Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Ashish Agarwal <agarwal1975@gmail.com>
To: sieira <jaimito.hendrix@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Doubt about function delaration parameter
Date: Wed, 15 Dec 2010 10:14:42 -0500	[thread overview]
Message-ID: <AANLkTinQYtsXoy-xOzE5PxOm8WLtSfWOPR8eq=tum1DS@mail.gmail.com> (raw)
In-Reply-To: <30464033.post@talk.nabble.com>

[-- Attachment #1: Type: text/plain, Size: 2439 bytes --]

Record field names must start with a lower case letter, so I cannot
reproduce the error you mention.

Also note you can simplify code like:

    print_string "foo"; ();

to simply

    print_string "foo"

Since print_string "foo" already returns unit, it is unnecessary to
explicitly return unit after this.


On Wed, Dec 15, 2010 at 9:03 AM, sieira <jaimito.hendrix@gmail.com> wrote:

>
> Why doesn't this work?:
>
> type menu = {Textos: string list; Claves:string list};;
>
> let menu_principal = {Textos = ["Clientes";"Operaciones"];Claves =
> ["1";"2"]};;
> let rec pinta_menu = function
>      {Textos = []; Claves = []} ->
>          begin
>            print_string ">";
>            ();
>          end
>      | {Textos = _; Claves = []} ->
>          begin
>            print_string "[EE] Error en el menu";
>            ();
>          end
>      | {Textos = []; Claves = _} ->
>          begin
>            print_string "[EE] Error en el menu";
>            ();
>            end
>      | {Textos = texto::textos; Claves = clave::claves} ->
>        begin
>          print_string texto^"Una dola\n";
>          pinta_menu({Textos = textos; Claves = claves});
>        end;;
>
>
> (Returns
>
> "This expression has type unit"
> )
>
> While this does:
>
> let rec pinta_menu = function
>      [],[] ->
>          begin
>            print_string ">";
>            ();
>          end
>      |  _,[] ->
>          begin
>            print_string "[EE] Error en el menu";
>            ();
>          end
>      | [];_} ->
>          begin
>            print_string "[EE] Error en el menu";
>            ();
>            end
>      | texto::textos;clave::claves ->
>        begin
>          print_string texto^"Una dola\n";
>          pinta_menu({Textos = textos; Claves = claves});
>        end;;
>
>        pinta_menu(menu_principal);;
>
>
> Note that Textos ean texts and Claves mean keys
>
>
>        pinta_menu(menu_principal);;
> --
> View this message in context:
> http://old.nabble.com/Doubt-about-function-delaration-parameter-tp30464033p30464033.html
> Sent from the Caml Discuss mailing list archive at Nabble.com.
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 3710 bytes --]

  reply	other threads:[~2010-12-15 15:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-15 14:03 sieira
2010-12-15 15:14 ` Ashish Agarwal [this message]
2010-12-15 15:18 ` Esther Baruk
2010-12-15 16:15 ` sieira
2010-12-15 16:37   ` David Allsopp
2010-12-15 16:56   ` Raphael Proust
2010-12-15 17:12     ` bluestorm

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='AANLkTinQYtsXoy-xOzE5PxOm8WLtSfWOPR8eq=tum1DS@mail.gmail.com' \
    --to=agarwal1975@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=jaimito.hendrix@gmail.com \
    /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