Walmart reported strong quarterly results, continuing to benefit from an increase in higher earners who were purchasing more groceries and discretionary items.