functions for getting length and nth of lists