Apply, a, is a command that lets the player 'use' an item, especially some form of tool. For example, you can apply a unicorn horn to remedy confusion, blindness, sickness, etc. You can also apply a pick-axe to break down a wall, a lamp to light it, a magic marker to write, etc. Various other non-tool items can be applied as well.
Certain weapons have a secondary function that can be accessed by applying them; these include most types of polearm, as well as the lance. Lances and polearms are applied to damage enemies from exactly two squares away, automatically wielding them in the process; see the article on pounding for details. Axes can be applied towards doors and trees in order to chop them down. Dwarvish mattocks can be applied the same way as pick-axes, but are considered weapons rather than tools.
Applying a wand breaks it, causing the magical energy to be unleashed all at once in an uncontrolled explosion; wands are usually used by zapping them with z. You need to have a minimum strength of 10 to break most wands. See Wand#Breaking wands for details.
Some artifacts share their base item types with tools, such as the Orb of Fate (an artifact crystal ball), and will function as that item when applied, separately of what powers it may have when invoked. In the cases of The Magic Mirror of Merlin and The Master Key of Thievery, this also produces a rumor that is true or false depending on its beatitude. The Bell of Opening and Candelabrum of Invocation, as items used for the Invocation Ritual, have more unique effects when applied; the Bell of Opening will act the same as a normal bell when applied with no charges, however.
Most tools with similar counterparts can be identified through applying them; e.g., you can identify each type of horn this way, although you should do so in a place where awakening nearby monsters or shooting beams of fire or ice will not cause problems.
Whistles are among the easiest tools to identify via applying; if "You produce a high whistling sound" then it is a tin whistle, but if "You produce a strange whistling sound" then it is a magic whistle. You might see other messages if the whistle is cursed or you are hallucinating.