Cog railways were designed for the very reason you stated, Tales. I was reading on some site that there is a cog railway in Switzerland that goes up a 48% grade! That toothed rail meshes with a gear in the engine and pulls the cab up and also allows it to go down slowly.
"What is a "Cog" Railway?
http://www.cograilway.com/history.htmConventional railroads use the friction of wheels upon the rails, called "adhesion", to provide locomotive power. A cog, or rack, railroad uses a gear, "cog wheel", meshing into a special rack rail (mounted in the middle between the outer rails) to climb much steeper grades than those possible with a standard adhesion railroad. An adhesion railroad can only climb grades of 4 to 6%, with very short sections of up to 9%. A "rack" railroad can climb grades of up to 48%, depending upon the type of rack system employed. Some Swiss trains use a combination of "rack" and "adhesion". This enables the trains to reach much higher speeds on the adhesion sections (rack railroads can not go much faster than 25 miles per hour or they run the risk of dislodgement from the rack rail- M & PP Ry.'s top speed is about 9 MPH)."