caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] laconical input from a file for arrays and/or matrices
@ 2004-02-02 10:42 Khamenia, Valery
  2004-02-02 10:57 ` samsaga2
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Khamenia, Valery @ 2004-02-02 10:42 UTC (permalink / raw)
  To: 'caml-list@inria.fr'

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
---------------------------------------------------------------------------
Bioinformatics Department
BioVisioN AG, Hannover

-------------------
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


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

end of thread, other threads:[~2004-02-02 15:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-02 10:42 [Caml-list] laconical input from a file for arrays and/or matrices Khamenia, Valery
2004-02-02 10:57 ` samsaga2
2004-02-02 14:20   ` Virgile Prevosto
2004-02-02 14:36 ` Richard Jones
2004-02-02 15:54 ` Issac Trotts

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).