Skip to main content
deleted 2 characters in body
Source Link
image_doctor
  • 10.3k
  • 24
  • 42

A variant using Take.

Take[list, #]list~Take~# & /@ Range@Length@list 

{{a}, {a, b}, {a, b, c}, {a, b, c, d}}

One using NestList:

NestList[Most, list, Length@list - 1] 

{{a, b, c, d}, {a, b, c}, {a, b}, {a}}

A variant using Take.

Take[list, #] & /@ Range@Length@list 

{{a}, {a, b}, {a, b, c}, {a, b, c, d}}

One using NestList:

NestList[Most, list, Length@list - 1] 

{{a, b, c, d}, {a, b, c}, {a, b}, {a}}

A variant using Take.

list~Take~# & /@ Range@Length@list 

{{a}, {a, b}, {a, b, c}, {a, b, c, d}}

One using NestList:

NestList[Most, list, Length@list - 1] 

{{a, b, c, d}, {a, b, c}, {a, b}, {a}}

added 113 characters in body
Source Link
image_doctor
  • 10.3k
  • 24
  • 42

A variant using Take.

Take[list, #] & /@ Range@Length@list 

{{a}, {a, b}, {a, b, c}, {a, b, c, d}}

One using NestList:

NestList[Most, list, Length@list - 1] 

{{a, b, c, d}, {a, b, c}, {a, b}, {a}}

A variant using Take.

Take[list, #] & /@ Range@Length@list 

{{a}, {a, b}, {a, b, c}, {a, b, c, d}}

A variant using Take.

Take[list, #] & /@ Range@Length@list 

{{a}, {a, b}, {a, b, c}, {a, b, c, d}}

One using NestList:

NestList[Most, list, Length@list - 1] 

{{a, b, c, d}, {a, b, c}, {a, b}, {a}}

Source Link
image_doctor
  • 10.3k
  • 24
  • 42

A variant using Take.

Take[list, #] & /@ Range@Length@list 

{{a}, {a, b}, {a, b, c}, {a, b, c, d}}