[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-apl] How to build a matrix without knowing its eventual size
From: |
Juergen Sauermann |
Subject: |
Re: [Bug-apl] How to build a matrix without knowing its eventual size |
Date: |
Wed, 02 Apr 2014 20:26:22 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 |
Hi,
depends a little on how the result should look like,
If you have a text with lines of different lengths then the most appropriate
for, IMHO, would be a nested vector with one ravel item per line. In
that case
collecting things in a Vector<Value_P> is probably the way to go (WARNING:
I have not tested that! Expect surprises).
If you want a flat result like a long char vector or a character matrix
then you
can use UCS_string or SimpleString<unsigned char> which provides efficient
append() functions like std::string. There are also constructors for APL
values from
UCS_strings.
Apart from that it is surprising that you can't get the number of rows
easily in SQLite - that looks
like a standard requirement to me.
Creating the ravel before the shape would be technically do-able but not
in line with how the rest
of GNU APL works. For example all the shape checks are normally done
before value checks so that,
for example, RANK ERROR occurs before DOMAIN ERROR and so on.
/// Jürgen
On 04/02/2014 05:57 PM, Elias Mårtenson wrote:
Right now I'm building the SQLite3 interface (but this will be an
issue in other cases too, for example if you need to build native code
to convert a CSV file to a matrix)
The problem with the SQLite3 API is that you don't know how many rows
the result will have until all the rows have been consumed. Thus, I'm
not able to create the Shape object until all the data has been read.
What is the best solution for this? Once thought was to buffer all the
Value_P objects in an std::vector and create the result matrix last.
But is there a better way? Is there a facility to dynamically extend
the size of the matrix as I put more objects into it?
Regards,
Elias