Hello all,
I have written the following function using for loop ,
which is the reason the output of the function is unit .
However , I want the function to return type list
Here is the code,
let rec get_col tname tdata colname =
let l2 = [] in
let narr = Array.length(List.hd(tdata)) in
let nlist = List.length(tdata) in
let cnt1 = 0 in
let cnt2 = 1 in
for cnt1 = 0 to (nlist - 1 )
do
(
for cnt2 = 0 to (narr-1)
do
(
if(
(fst(Array.get(Hashtbl.find t cnt1 ) cnt2)) = colname )
then
(
let str = extract_data(snd(Array.get ( Hashtbl.find t cnt1)
cnt2 )) in
let l2 = str :: l2 in
let cnt2 = cnt2 + 1 in
cnt1 = cnt1 + 1;
print_string (List.hd(l2));
)
else
(
let str = "" in
let l2 = str :: l2 in
cnt2 = cnt2 + 1 ;
print_string (List.hd(l2));
)
)
done;
)
done;;
the input variable tname is a string , tdata is of type table.tb_data
whose definition is as follows ,colname is a string ,
type field_type = Int of int | Bool of bool | Float of float | String
of string | Char of char;;
type field = Some of field_type | None;;
type table_defn = (string * ( string * int * int )) array ;;
type table_data = (string * field) array ;;
type table = { name : string; tb_defn : table_defn list ; tb_data :
table_data list };;
Please let me know what you feel , how I can get the function to
returna list..
Regards,
AB
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ocaml-developer" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/ocaml-developer?hl=en
For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html
-~----------~----~----~----~------~----~------~--~---