Optical implementation of programmable associative memories