func (g *Guest) getPreferredPlatform() *Platform { getPlatform := func(o interface{}) interface{} { return o.(*Offer).Platform } var offers offerSlice = lastOffers(g.boughtOffers, cognitiveLoad) platforms := util.Map(getPlatform, offers) platform, count := util.MaxOccur(platforms) if count <= cognitiveLoad/5 { return nil } return platform.(*Platform) }
func (g *Guest) getPreferredHotel() *Hotel { getHotel := func(o interface{}) interface{} { return o.(*Offer).Hotel } var offers offerSlice = lastOffers(g.boughtOffers, cognitiveLoad) hotels := util.Map(getHotel, offers) hotel, count := util.MaxOccur(hotels) if count <= cognitiveLoad/5 { return nil } return hotel.(*Hotel) }