Open buddha314 opened 7 years ago
Some historical context: Our original thinking with push_back
was to restrict the functionality to domains with only one array because it might be surprising to users if calling push_back
on one array changed the elements of some unrelated array elsewhere.
@bradcray : do you have any thoughts on how we could make this pattern more elegant?
Honestly, that makes sense to me. I'm wondering if we can't (a) create an operator on the domain itself that increases it by a given amount and (b) returns the new indices for quick population.
To illustrate (a)
tea_prices.push_back(4.8); // affects temperature and causes a surprise, so ERROR (?)
dates.push_back("2006-04-24"); // affects both tea_prices and temperature as an index,
// but both are in sync so no surprise, operating at index
To illustrate (b), now I want to use that new date for the price/temp.
var today = dates.push_back("2006-04-24");
tea_price[today] = 4.8;
I don't know if this breaks thinking, but it seems useful.
@bradcray : do you have any thoughts on how we could make this pattern more elegant?
The main thing that comes to mind for me would be a variation on push_back
and friends that could be called on a tuple of arrays, providing a new element per array. So imagine:
(dates, tea_price).push_back(("2006-04-24", 4.8));
Here is the use case.
I have a domain. Here, just integers but think dates.
If I only have
tea_price
then I can dotea_price.push_back(4.5)
and it expandsdates
by one. However, with bothtea_price
andtemperature
I can't usepush_back()
. I think this would be usefulAt the moment, I can only think of
This could be extremely helpful for time series analysis. In this way, a domain is a sort of external index to multiple collections rather than an array of things. I am probably thinking of this the wrong way, but I figured I'd ask...