From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id D4C04BC58 for ; Wed, 15 Dec 2010 16:18:45 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsAAAhrCE3RVdazk2dsb2JhbACCF5MzhjIBiCMIFQEBAQEJCQoJEQQgqEqJcIIYhR4uiFcBAQMFgxwBgigEgWCJG4YI X-IronPort-AV: E=Sophos;i="4.59,349,1288566000"; d="scan'208,217";a="92446122" Received: from mail-iw0-f179.google.com ([209.85.214.179]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 15 Dec 2010 16:18:45 +0100 Received: by iwn42 with SMTP id 42so2217877iwn.10 for ; Wed, 15 Dec 2010 07:18:43 -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=WTFsXUTV+U37kr7zhzsJ70WnQ84YQCteoJmOQSAAZEU=; b=UzgRcPqUfRhbS5SuAdwAPzQsP/1VCQTbYXl6rOtjDW9kEf2SbN1+UVUGe/gH4k2csl T4g3TDkAKqe5P1nVpN0KYsOVyAEJP95REyp4yHQJYfWkyicPOhuMwQ8O7bO+p2GGH4L5 hl0o1KiSzrRwcZah1mgM+z4WiAyZyLFboJSqk= 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=ArMBBeekFaknRWjRkGuHTWZz/a99CCreG8gJuZODqYiNG7IdYFm8D7iX/udI8VcY09 ROxVF8iWyADcZrH4zhWGOMy/bpLMN+N0HA4t/QnfdDlOr2JiCctmEJl5LzKwqE5SUu6E kXzfEKhaLC2TYGohE9VKvj16LbJ/jtZimcyUo= Received: by 10.231.31.4 with SMTP id w4mr4927273ibc.140.1292426323701; Wed, 15 Dec 2010 07:18:43 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.31.197 with HTTP; Wed, 15 Dec 2010 07:18:23 -0800 (PST) In-Reply-To: <30464033.post@talk.nabble.com> References: <30464033.post@talk.nabble.com> From: Esther Baruk Date: Wed, 15 Dec 2010 16:18:23 +0100 Message-ID: Subject: Re: [Caml-list] Doubt about function delaration parameter To: sieira Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=0022152d7c5fec315904977473f2 X-Spam: no; 0.01; beginner's:01 ocaml:01 bug:01 beginner's:01 ocaml:01 bug:01 textos:98 claves:98 textos:98 clientes:98 claves:98 sans-serif:98 sans-serif:98 beginners:01 beginners:01 --0022152d7c5fec315904977473f2 Content-Type: text/plain; charset=ISO-8859-1 When you write : print_string texto^"Una dola\n"; you must put parenthesis around your string : print_string (texto^"Una dola\n"); Otherwise it means you concatenates a string with a thing of type unit. Esther 2010/12/15 sieira > > 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 > --0022152d7c5fec315904977473f2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable When you write :

=A0print_string tex= to^"Una dola\n";

<= span class=3D"Apple-style-span" style=3D"border-collapse: collapse;">you mu= st put parenthesis around your string :=A0print_string (texto^"Una dola\n");

Otherwise it means you concatenate= s a string with a thing of type unit.

<= span class=3D"Apple-style-span" style=3D"border-collapse: collapse;">
Esther


2010/12/15 sieira <= jaimito.hendrix@gmail.com&= gt;

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

--0022152d7c5fec315904977473f2--