I have lists of values as seen below:
function(obj){
var props = Object.keys(obj), p = Promise.resolve();
props.forEach(function(prop){
p = p.then(function(){
if(condition){ // can access obj[prop] and obj here
obj.children = example.getData(...); // getData returns a promise
return obj.children; // return the promise.
}
});
});
Promise.resolve(obj.children).then(function(children){
// here the async call to get `.children` is done.
// can wait for `p` too (the loop) if we care about it
if(obj.length === 10) // do stuff
});
I obtain the list above by using the append within a for loop where Mw_Price is Mw(51) and Price(4889.37) for each iteration
[(51, 4889.37), (58, 5582.51), (62, 6005.07), (67, 6533.27)]
Is there an append to a dict?
I need my output to be as such:
new_list.append(Mw_Price)
答案 0 :(得分:1)
From your rough description of your code (please include actual code for best answers), you can probably do something like:
SELECT num, SUM(amount) AS total
FROM amounts LEFT JOIN numbers ON amounts.nr=numbers.num
GROUP BY num;
to get the result you want.
答案 1 :(得分:0)
You'd probably better unpack the pairs into two separate variables in the first place:
this._worker = new Worker( Physijs.scripts.worker || 'physijs_worker.js' );
Or if you insist on loop-and-append:
old_list = [(51, 4889.37), (58, 5582.51), (62, 6005.07), (67, 6533.27)]
new_list = [{'Mw': mw, 'Price': price} for mw, price in old_list]