pure functional forEach alternative with optional completion callback