Extract function

Extract or replace part of an boolean vector