Fix #2417 - Use apply to implement slice.