Implement cld

This implements the "cld" function as suggested in #7132.