avg_wtd res = list:fold_left (&_, items, (p_avg_wtd -&w res, p_item _) {
                                                                         with (res)
                                                                         {
                                                                           ->weight += 1;
                                                                           ->total += item->price * ->weight;
                                                                           ->divider += ->weight;
                                                                         }
                                                                       });

avg_wtd res = list:fold_right (&_, items, (p_avg_wtd -&w res, p_item _) {
                                                                         with (res)
                                                                         {
                                                                           ->weight += 1;
                                                                           ->total += item->price * ->weight;
                                                                           ->divider += ->weight;
                                                                         }
                                                                        });

int total = list:reduce_left (items, (int total, p_item _) {
                                                             ...
                                                           });

int total = list:reduce_right (items, (int total, p_item _) {
                                                              ...
                                                            });
