On Sun, 23 Jun 2019, Allin Cottrell wrote:
sscanf() could also do the job (element by element). But it might be
nice to
enable something like
matrix m
sscanf(S, "%m", m)
to scan an array of numeric strings (S) into a matrix in one go.
Thank you, this is very useful. The version that is in git now, however,
does not handle non-numeric entries, which could be a bit of a nuisance
sometimes. Example:
<hansl>
c = defarray("2", "1.0", "NA", "1")
m = {}
sscanf(c, "%m", &m)
print m
</hansl>
returns
<output>
m (2 x 1)
2
1
</output>
However, before plunging into the code, I'd like to point out that this is
just a special case of
<hansl>
s = sprintf("1 2\nfoobarbaz 3")
m = {}
sscanf(s, "%m", &m)
print m
</hansl>
which returns (rightly, IMO)
<output>
m (1 x 2)
1 2
</output>
so I'm not sure what we should do. Opinions?
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------