Reciprocating electric motor

A reciprocating electric motor is a motor in which the armature moves back and forth rather than circularly. Early electric motors were sometimes of the reciprocating type, such as those made by Daniel Davis in the 1840s. Today, reciprocating electric motors are rare but they do have some niche applications, e.g. in linear compressors for cryogenics and as educational toys.
History.
Daniel Davis was an early maker of reciprocating electric motors.
As can be seen in these examples, early motors of this type often followed the general layout of the steam engines of the day, 
simply replacing the piston-and-cylinder with an electromagnetic solenoid. 
Design.
A reciprocating electric motor uses an alternating magnetic field to move its armature back and forth, rather than circularly as in a conventional electric motor. A single field coil may be placed at one end of the armature's possible movement, or a field coil may be used at each end.
The armature may be a permanent magnet, in which case the coil or coils can exert both repulsive and attractive force on the armature. If there are two coils, they will be wound and connected so that their like poles face each other, so that when (for example) the poles facing the armature are both negative, one pole will attract the armature's south pole while the other will repel its north pole. When the armature reaches the extreme of its movement, polarity to the coils is reversed.
The armature may instead be made of ferromagnetic material, as in an electromagnetic solenoid. In this case the current in the coils will alternate between on and off, rather than between polarities. A single-coil motor with a non-magnetic armature would require a spring or some other "return" mechanism to move the armature away from the coil upon completion of the "attract" cycle. An "interrupter"-style electromechanical buzzer operates on this same principle. A dual-coil motor would alternately energize the two coils. Where the motor is adapted to produce rotary motion, the return mechanism consists of a crankshaft and flywheel.
This is an extremely simple motor, such that demonstration models may be easily constructed for teaching purposes. As a practical motor it has several disadvantages. Magnetic field strength drops off rapidly with increasing distance. In the reciprocating electric motor the distance between armature and field coil must necessarily increase considerably over its minimum value; this reduces the motor's output power and starting force. Vibration is also an issue.
Applications.
Linear compressors.
A design for a linear compressor of this type has been produced by the Cryogenic Engineering Group at the University of Oxford.
Pumps.
See Plunger pump
Electric shavers.
Some electric shavers use reciprocating motors.
Toys.
Educational toys can be built as DIY projects. Some of them have even been patented (for e.g. one in 1929, another in 1963).