Factor, 68 bytes
[ { 2 } swap [ reverse [ 1 + <array> ] map-index concat ] times Σ ] Explanation:
It's a quotation (anonymous function) that takes an integer from the data stack as input and puts an integer (the nth term of the Levine sequence) on the data stack as output. Assuming 4 is on top of the stack when this quotation is called...
{ 2 }Push a sequence to the stack containing one element,2.Stack:
4 { 2 }swapSwap two objects (becausetimesneeds access to the4later).Stack:
{ 2 } 4[ reverse [ 1 + <array> ] map-index concat ]Push a quotation fortimesto use later. This is a quotation that produces the next row of the Levine's Triangle from the previous one.Stack:
{ 2 } 4 [ reverse [ 1 + <array> ] map-index concat ]timesCall a quotation a certain number of times. Inside the quotation now for the first iteration...Stack:
{ 2 }reverseReverse a sequence.Stack:
{ 2 }[ 1 + <array> ]Push a quotation formap-indexto use later.Stack:
{ 2 } [ 1 + <array> ]map-indexTake a sequence and a quotation and apply the quotation to each element of the sequence, collecting the results into a new sequence of the same length. However, it also places the index of the element on top of the stack. Inside the quotation now for the first iteration...Stack:
2 01Push1.Stack:
2 0 1+Add.Stack:
2 1<array>Create an array from a count and an element.Stack:
{ 1 1 }Now
map-indexhas exhausted its elements. Since we are mapping numbers to arrays, the result will be an array of arrays.Stack:
{ { 1 1 } }concatConcatenate a sequence of sequences together into one sequence.Stack:
{ 1 1 }Now we have produced the second row of Levine's Triangle.
timeswill run the quotation three more times...Stack:
{ 1 1 2 3 }ΣSum a sequence.Stack:
7