A programmable chemical computer with memory and pattern recognition