Mechanical transistors for logic-with-memory computing