Add support for the limit function.

The limit function takes a metric or wildcard list of metrics
and a limit (n). The function returns the first n metrics
from the given list of metrics.