Constructing an associative memory