Programming by Demonstration for Shared Control with an Application in Teleoperation