From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 5389CBC57 for ; Wed, 15 Dec 2010 16:15:09 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiMBAMtpCE3RVdK2mWdsb2JhbACVSYYyAYgjCBUBAQEBAQgLCgcRJKg/iXCCGIUgLohXAQEDBYVFBIFggwSGF4YI X-IronPort-AV: E=Sophos;i="4.59,349,1288566000"; d="scan'208";a="82829232" Received: from mail-iy0-f182.google.com ([209.85.210.182]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Dec 2010 16:15:03 +0100 Received: by iyb26 with SMTP id 26so1016096iyb.27 for ; Wed, 15 Dec 2010 07:15:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type; bh=XzAy4w10K+vRrYV8IQMN6HvrrswZb0Yyele7LIoGhy0=; b=eZtSyNkkmgVv2LnfSknwGH3KqF4R7O7ietGrfpbCW1hvaA5Y+CNHSQa76lYGDW+Y1l A/HiQ12ATedRWYSghpfifDjD4oqBN8ZP0NCO+yc8IEYvETK0WRSkLdomWuob8qMrqoQz kNmuopDGq4evfHgPm9+2fYU8dnoSrT6hYqUTI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=erYnkWoiaSO5ZvwAk0z9tSDOQsKu7WV1yPo59QTiJ5qpvQ5BZigeunjpFit0vALcYB iVjWyf7JV1+1B/qj7niYBhW4LSrFpYXvI5Uh4r0Authv2k0aIJTUgmvRHSFTJEOmGoK4 I7hDWibnBPuVoGxRbmQf17/pxgMKaEizoUQoE= Received: by 10.231.205.132 with SMTP id fq4mr4955221ibb.17.1292426102999; Wed, 15 Dec 2010 07:15:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.14.10 with HTTP; Wed, 15 Dec 2010 07:14:42 -0800 (PST) In-Reply-To: <30464033.post@talk.nabble.com> References: <30464033.post@talk.nabble.com> From: Ashish Agarwal Date: Wed, 15 Dec 2010 10:14:42 -0500 Message-ID: Subject: Re: [Caml-list] Doubt about function delaration parameter To: sieira Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=90e6ba4fc3a0c48c8104977466bf X-Spam: no; 0.00; foo:01 foo:01 beginner's:01 ocaml:01 bug:01 beginner's:01 ocaml:01 bug:01 1975:98 textos:98 claves:98 textos:98 clientes:98 claves:98 beginners:01 --90e6ba4fc3a0c48c8104977466bf Content-Type: text/plain; charset=ISO-8859-1 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 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 > --90e6ba4fc3a0c48c8104977466bf Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Record field names must start with a lower case letter, so I cannot reprodu= ce the error you mention.

Also note you can simplify cod= e like:

=A0=A0 =A0print_string "foo"; ()= ;=A0

to simply

=A0=A0 =A0print_stri= ng "foo"

Since print_string "foo&qu= ot; 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 =3D {Textos: string list; Claves:string list};;

let menu_principal =3D {Textos =3D ["Clientes";"Operaciones&= quot;];Claves =3D
["1";"2"]};;
let rec pinta_menu =3D function
=A0 =A0 =A0{Textos =3D []; Claves =3D []} ->
=A0 =A0 =A0 =A0 =A0begin
=A0 =A0 =A0 =A0 =A0 =A0print_string ">";
=A0 =A0 =A0 =A0 =A0 =A0();
=A0 =A0 =A0 =A0 =A0end
=A0 =A0 =A0| {Textos =3D _; Claves =3D []} ->
=A0 =A0 =A0 =A0 =A0begin
=A0 =A0 =A0 =A0 =A0 =A0print_string "[EE] Error en el menu";
=A0 =A0 =A0 =A0 =A0 =A0();
=A0 =A0 =A0 =A0 =A0end
=A0 =A0 =A0| {Textos =3D []; Claves =3D _} ->
=A0 =A0 =A0 =A0 =A0begin
=A0 =A0 =A0 =A0 =A0 =A0print_string "[EE] Error en el menu";
=A0 =A0 =A0 =A0 =A0 =A0();
=A0 =A0 =A0 =A0 =A0 =A0end
=A0 =A0 =A0| {Textos =3D texto::textos; Claves =3D clave::claves} -> =A0 =A0 =A0 =A0begin
=A0 =A0 =A0 =A0 =A0print_string texto^"Una dola\n";
=A0 =A0 =A0 =A0 =A0pinta_menu({Textos =3D textos; Claves =3D claves});
=A0 =A0 =A0 =A0end;;


(Returns

"This expression has type unit"
)

While this does:

let rec pinta_menu =3D function
=A0 =A0 =A0[],[] ->
=A0 =A0 =A0 =A0 =A0begin
=A0 =A0 =A0 =A0 =A0 =A0print_string ">";
=A0 =A0 =A0 =A0 =A0 =A0();
=A0 =A0 =A0 =A0 =A0end
=A0 =A0 =A0| =A0_,[] ->
=A0 =A0 =A0 =A0 =A0begin
=A0 =A0 =A0 =A0 =A0 =A0print_string "[EE] Error en el menu";
=A0 =A0 =A0 =A0 =A0 =A0();
=A0 =A0 =A0 =A0 =A0end
=A0 =A0 =A0| [];_} ->
=A0 =A0 =A0 =A0 =A0begin
=A0 =A0 =A0 =A0 =A0 =A0print_string "[EE] Error en el menu";
=A0 =A0 =A0 =A0 =A0 =A0();
=A0 =A0 =A0 =A0 =A0 =A0end
=A0 =A0 =A0| texto::textos;clave::claves ->
=A0 =A0 =A0 =A0begin
=A0 =A0 =A0 =A0 =A0print_string texto^"Una dola\n";
=A0 =A0 =A0 =A0 =A0pinta_menu({Textos =3D textos; Claves =3D claves});
=A0 =A0 =A0 =A0end;;

=A0 =A0 =A0 =A0pinta_menu(menu_principal);;


Note that Textos ean texts and Claves mean keys


=A0 =A0 =A0 =A0pinta_menu(menu_principal);;
--
View this message in context: h= ttp://old.nabble.com/Doubt-about-function-delaration-parameter-tp30464033p3= 0464033.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.in= ria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--90e6ba4fc3a0c48c8104977466bf--