Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] laconical input from a file for arrays and/or matrices
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: samsaga2 <samsaga2@s...>
Subject: Re: [Caml-list] laconical input from a file for arrays and/or matrices
let output_matirx m = output_value stdout m
let input_matrix () = input_value stdin

But no compatible with c++ files :-P

Khamenia, Valery wrote:

>Hi OCaMLers,
>
>  here goes my usual way to input ASCII matrices from file in C++:
>
>//  -------  start of fragment -----------
>#include <iostream>
>#include <vector>
>using namespace std;
>
>void input_matrix(vector<vector<double > >&vec) {
>  int m, n;
>  cin >> m;
>  cin >> n;
>  vec.resize (m);
>  for( int i = 0; i<m; i++)
>    vec[i].resize(n);
>  for( int i = 0; i<m; i++)
>    for( int j = 0; j<n; j++) 
>      cin >> vec[i][j]; 
>}
>//  -------- end of fragment -------------
>
>then for matrix :
>
>  3
>  3
>  1 2 3 
>  4 5 6
>  7 8 9
>
>stored in ASCII text file mymatrix.dat
>
>i just run my program:
>
> % myprogram < mymatrix.dat
>
>and it is done.
>
>Thus, the few lines of code and i can apply all math I need. 
>
>Is there any similar ascetic way in OCaML for 
>doing the same?
>
>Thanks a priori,
>kind regards,
>Valery A.Khamenya
>

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners