Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Doubt about function delaration parameter
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: sieira <jaimito.hendrix@g...>
Subject: [Caml-list] Doubt about function delaration parameter

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.