caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Doubt about function delaration parameter
@ 2010-12-15 14:03 sieira
  2010-12-15 15:14 ` Ashish Agarwal
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: sieira @ 2010-12-15 14:03 UTC (permalink / raw)
  To: caml-list


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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-12-15 17:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-15 14:03 [Caml-list] Doubt about function delaration parameter sieira
2010-12-15 15:14 ` Ashish Agarwal
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).