Q:

How to Access the List Indices

I have a list of numbers (index positions really) like so:
> original
[[1]]
[1] 99 100

[[2]]
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

[[3]]
 [1] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

[[4]]
 [1] 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

I would like to return another list which replicates each of the indices of the original list according to the length of the sublists.   Specifically, the results should look something like:
> result
    [[1]]
    [1] 1 1

because 1 is the index of the original and its length is 2
    [[2]]
     [1] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

because 2 is the index of the original and its length is 26
    [[3]]
     [1]  3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 

because 3 is the index of the original and its length is 27
In my mind, as long as I can access the index position, it should look something like this:
lapply(original, function(x) rep(index(x), length(x)))

This fails because I apparently cannot access the index of the list within lapply in this way, nor any other way I have tried. 
anybody out there done this before? 

A:

You can use mapply here to access the index as well as the list elements. 
mapply(function(x, y) rep(x, length(y)), seq_along(original), original)

#[[1]]
#[1] 1 1 1

#[[2]]
#[1] 2 2

#[[3]]
#[1] 3 3 3 3 3 3 3 3

Taking a different example as it is easy to reproduce. 
data
original <- list(c(1:3), c(4, 5), c(1:8))

original
#[[1]]
#[1] 1 2 3

#[[2]]
#[1] 4 5

#[[3]]
#[1] 1 2 3 4 5 6 7 8

Few other options : 
Using only lapply
lapply(seq_along(original), function(x) rep(x, length(original[[x]])))

and using map2 from purrr
library(purrr)
original %>% map2(.y=seq_along(original),~rep(.y,length(.x)))

A:

You could relist() a vector of indices, using the original list as the skeleton.  
relist(rep(seq_along(original), lengths(original)), original)
# [[1]]
# [1] 1 1 1
#
# [[2]]
# [1] 2 2
#
# [[3]]
# [1] 3 3 3 3 3 3 3 3

Data:
original <- list(1:3, 4:5, 1:8)

