See the original description in base::lengths.
lengths(x, use.names = TRUE)# get function from namespace instead of possibly getting
# implementation shipped with recent R versions:
bp_lengths = getFromNamespace("lengths", "backports")
bp_lengths(list(1:3, 2))
#> [1] 3 1