Nonvolatile Memory and Programmable Logic from Molecule-Gated Nanowires