offers: comment out much of this experimental API until we have tests, and a better road map
@@ -121,40 +121,32 @@ func (s Index) ToSlice() (slice Slice) {
return
}
-type (
- Reducer interface {
- Reduce(_, _ *Offer) *Offer
- }
-
- ReduceFunc func(_, _ *Offer) *Offer
-)
-
-func (f ReduceFunc) Reduce(a, b *Offer) *Offer { return f(a, b) }
+/*
-var _ = Reducer(ReduceFunc(func(_, _ *Offer) *Offer { return nil })) // sanity check
+type Reducer func(_, _ *Offer) *Offer
-func (slice Slice) Reduce(def Offer, r Reducer) (result Offer) {
- result = def
- if r != nil {
+func (slice Slice) Reduce(r Reducer) (result Offer) {
+ if r == nil {
+ return
+ }
acc := &result
for i := range slice {
- acc = r.Reduce(&result, &slice[i])
+ acc = r(&result, &slice[i])
}
if acc == nil {
result = Offer{}
} else {
result = *acc
}
- }
return
}
-func (index Index) Reduce(def *Offer, r Reducer) (result *Offer) {
- result = def
- if r != nil {
- for i := range index {
- result = r.Reduce(result, index[i])
+func (index Index) Reduce(r Reducer) (result *Offer) {
+ if r == nil {
+ return
}
+ for i := range index {
+ result = r(result, index[i])
}
return
}
@@ -245,3 +237,4 @@ func (index Index) Reindex(kf KeyFunc) Index {
}
return result
}
+*/
