[Question]
  [
## Background
**-rot transform** (read as "minus-rot transform") is a sequence transformation I just invented. This transform is done by viewing the sequence as a stack in Forth or Factor (first term on the top) and repeatedly applying `-rot +`. `-rot` is a command that moves the top of the stack to two places down, and `+` adds two numbers on the top of the stack.
For example, applying -rot transform to the sequence `[1, 2, 3, 4, 5, 6, 7, 8, 9]` looks like this (the right side is the top of the stack in this example, to match Forth/Factor conventions):
```
initial: 9 8 7 6 5 4 3 2 1 <--
-rot   : 9 8 7 6 5 4 1 3 2
+      : 9 8 7 6 5 4 1 5 <--
-rot   : 9 8 7 6 5 5 4 1
+      : 9 8 7 6 5 5 5 <--
-rot   : 9 8 7 6 5 5 5
+      : 9 8 7 6 5 10 <--
-rot   : 9 8 7 10 6 5
+      : 9 8 7 10 11 <--
-rot   : 9 8 11 7 10
+      : 9 8 11 17 <--
-rot   : 9 17 8 11
+      : 9 17 19 <--
-rot   : 19 9 17
+      : 19 26 <--
```
`-rot` does not work when there are only two items on the stack, so the operation stops there. Then the top of the stack at the initial state and after each `+` command are collected to form the resulting sequence of `[1, 5, 5, 10, 11, 17, 19, 26]`. Note that it is one term shorter than the input sequence.
## Task
Given a finite sequence of integers (of length ≥ 3), compute its -rot transform.
Standard [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") rules apply. The shortest code in bytes wins.
## Test cases
```
[1, 2, 3] -> [1, 5]
[1, -1, 1, -1, 1, -1, 1, -1] -> [1, 0, 0, 1, -1, 2, -2]
[1, 2, 3, 4, 5, 6, 7, 8, 9] -> [1, 5, 5, 10, 11, 17, 19, 26]
[1, 2, 4, 8, 16, 32, 64, 128] -> [1, 6, 9, 22, 41, 86, 169]
[1, 0, -1, 0, 1, 0, -1, 0, 1] -> [1, -1, 1, 0, 1, -1, 1, 0]
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 8 bytes
```
Ä2œPF_@\
```
[Try it online!](https://tio.run/##y0rNyan8//9wi9HRyQFu8Q4x////jzbUMdIx0bHQMTTTMTbSMTPRMTSyiAUA "Jelly – Try It Online")
Based on the older approach below. `Ä` generates cumulative sums, and `2œPF` (ew) throws away the second one. Then `\` scanning by `_@` flipped subtraction gives:
```
    [a,
     a+b+c-(a),
     a+b+c+d-(a+b+c-(a)),
     a+b+c+d+e-(a+b+c+d-(a+b+c-(a))),
     ...]
    = [a, b+c, a+d, b+c+e, ...]
```
I feel like there has to be something shorter than `2œPF` to remove the 2nd element of a list.
# Jelly, ~~9~~ 8 bytes
```
Jḟ2b1^\ḋ
```
[Try it online!](https://tio.run/##y0rNyan8/9/LzsjZ@tDSmIc7uh7u6P7//3@0oY6CkY6CiY6ChY6CoZmOgjGQZwbkGhpZxAIA "Jelly – Try It Online")
Based on rak1507's observation that when the input is \$[a,b,c,d,e,f...]\$, the answer is $$[a, ~~b + c, ~~a + d, ~~b + c + e, ~~a + d + f, \dots].$$
That is: cumulative sums of even and odd elements, but with the first two elements swapped.
That means we can calculate (`ḋ` is dot product, padding the shorter argument with 0s at the end):
```
ḋ(input, [1]) = a
ḋ(input, [0, 1, 1]) = b + c
ḋ(input, [1, 0, 0, 1]) = a + d
ḋ(input, [0, 1, 1, 0, 1]) = b + c + e
ḋ(input, [1, 0, 0, 1, 0, 1]) = a + d + f
ḋ(input, [0, 1, 1, 0, 1, 0, 1]) = b + c + e + g
...
```
In this program, `Jḟ2b1^\` computes the triangle `[[1], [0,1,1], [1,0,0,1]…]` and `ḋ` takes dot products with the input.
`Jḟ2` is `[1,3,4,5,…,n]`. `b1` generates lists of 1s of those lengths, and `^\` is a XOR scan.
[Answer]
# [Python 3](https://docs.python.org/3/), ~~53~~ 47 bytes
```
f=lambda a,b,*r:(a,)+(r and f(b+r[0],a,*r[1:]))
```
A variadic function that takes the integers as separate arguments and returns a tuple. [Try it online!](https://tio.run/##bY7BCoMwEETvfsUco27BqLVW6JeEHGI1VKhRYi79ertVBA9dWHZn3zLM/AmvyRXrah9vM7adgaGWEt8IQ3EqPIzrYEWbepVpMkyUbHQcr3byCP0SnmbpMTioCEoSckKhad8v3H/GgX@vhJJwJVSEG6Em3E@03C6SWcGqYinz@uDZ7phtpiehI@gmAtfsBxeEFckRk1N/AQ "Python 3 – Try It Online")
### Explanation
```
f=lambda a,b,*r:(a,)+(r and f(b+r[0],a,*r[1:]))
f=                                              # Define f to be
  lambda a,b,*r:                                # a function of at least two arguments
                                                # where a,b are the first two args
                                                # and any args beyond those are
                                                # put in a tuple and assigned to r
                (a,)                            # Tuple containing a
                    +                           # Add (concat) this tuple:
                     (r and                   ) # If r is falsey (empty), then r
                            f(               )  # Else, recursive call with:
                              b+r[0],           # The second arg plus the third
                                     a,         # followed by the first arg
                                       *r[1:]   # followed by all the rest
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~11~~ 10 bytes
```
-œ?UŒœÄZFḊ
```
Thank you very much to caird/Dude/ChartZ for helping golf this in TNB.
-1 thanks to Lynn!
Explanation:
I tried to look for a pattern that could be used to solve this more easily, so a quick [sage script](https://sagecell.sagemath.org/?z=eJyFj8sKgzAQRfeC_3C7MsGp0C4FvyS4iBofYG2Its3nd0ItLvpwVsO5986jMS3cIrzM4whcHgW8yvPjqXwBZ2ZGyismK3r0w2gwmoljOBQ4r9lQmlAR6jAls1crJH00m9kj5dEhghR1uQm8NNPWmqkRVVrL9yXLzU1B24xxNA7zIi7airt2hERXdWPark8kp6wbpkXwe2o9q_xKCc1PgWD-aYR2RyZ0-w5Cz6YneUllfw==&lang=sage&interacts=eJyLjgUAARUAuQ==) did the trick.
From that, we get the pattern
```
[a, b + c]
[a, b + c, a + d]
[a, b + c, a + d, b + c + e]
[a, b + c, a + d, b + c + e, a + d + f]
[a, b + c, a + d, b + c + e, a + d + f, b + c + e + g]
[a, b + c, a + d, b + c + e, a + d + f, b + c + e + g, a + d + f + h]
```
From this, we can see it is an interleaved cumulative sum of [a, d, f, h...] and [b, c, e, g...]. Flipping a and b makes this nicer, [b, d, f, h...] and [a, c, e, g...].
```
-œ?UŒœÄZFḊ
-           -1
 œ?         -1th ordered permutation, i.e. second-from-last. This will always be the array reversed with the last 2 elements swapped
   U        un-reverse
    Œœ      uninterleave
      Ä     cumulative sum 
       Z    zip
        F   flatten
         Ḋ  tail
```
[Try it online!](https://tio.run/##y0rNyan8/1/36GT70KOTjk4@3BLl9nBH1//D7Y@a1vz/H22oo2Cko2Acq6MAYuoCMRYKImukY6xjomOqY6ZjrmOhYwnVAtRtoqNgAVRpBjQHyDMDcg2NLKDSBhBjDMAmIXFiAQ "Jelly – Try It Online")
[Answer]
# [convey](http://xn--wxa.land/convey/), 55 bytes
```
 3!<
v<#/`:<
?:"  \&
v?~`"#:}
>#>>,^^
 ?v v^-1
 >+>,,\{
```
[Try it online!](https://xn--wxa.land/convey/run.html#eyJjIjoiIDMhPFxudjwjL2A6PFxuPzpcIiAgXFwmIFxudj9+YFwiIzp9XG4+Iz4+LF5eXG4gP3Ygdl4tMVxuID4rPiwsXFx7IiwidiI6MSwiaSI6IjEgMiAzIDQgNSA2IDcgOCA5In0=)
Lower right part is letting `length(input) - 1` elements to the output.
Top right part buffers the input for too long inputs, as the row would otherwise attach to itself.
Top left we get a `3` for each iteration: this splits off the first three elements and lets the head wait for 3 extra steps before copying it into the output and then rejoining with the main row. Because the head blocks the tile while waiting, the other 2 elements go into the `+` before joining the row again.
[![enter image description here](https://i.stack.imgur.com/sqO1s.gif)](https://i.stack.imgur.com/sqO1s.gif)
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), ~~47~~ 46 bytes
*-1 byte thanks to [Wheat Wizard](https://codegolf.stackexchange.com/users/56656/wheat-wizard)*
```
[A,B|T]/[A|R]:-T=[C|U],S is B+C,[S,A|U]/R;T=R.
```
[Try it online!](https://tio.run/##KyjKz8lP1y0uz/z/P9pRx6kmJFY/2rEmKNZKN8Q22rkmNFYnWCGzWMFJ21knOljHESigH2QdYhuk999KVyHaUMdIx1jHRMdUx0zHXMdCxxIom1pcmlOio1BelFmSqgHhaer9BwA "Prolog (SWI) – Try It Online")
### Explanation
We define `/` as an infix predicate that takes a list as its left argument and sets its right argument to the -rot transformed list.
```
[A,B|T]/[A|R] :-
```
The left argument must have at least two elements, `A` and `B`. Any elements beyond the second are put in `T`. The right argument will always start with `A`; the rest of it will be `R`, which we calculate in one of two ways:
```
T=[C|U], S is B+C, [S,A|U]/R
```
Recursive case: if `T` has at least one element, we put the first element of `T` into `C` and the rest of `T` into `U`. Next, we calculate the sum of `B` and `C` and put it in `S`. Then we do a recursive call with the list `[S,A|U]`: the sum `S`, followed by the first element `A`, followed by all the elements in `U`. The result of that recursive call is put in `R`.
```
; T=R
```
If `T` is empty, the unification `T=[C|U]` fails, and we fall back to the base case: `R` is the empty list (i.e. `T`).
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 8 bytes
```
÷^!‹(…∇+
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%C3%B7%5E!%E2%80%B9%28%E2%80%A6%E2%88%87%2B&inputs=%5B1%2C%20-1%2C%201%2C%20-1%2C%201%2C%20-1%2C%201%2C%20-1%5D&header=&footer=)
Woo using a stack based language to solve a stack based problem. Outputs each item on a newline. [11 bytes to output as list](https://lyxal.pythonanywhere.com?flags=&code=%C3%B7%5E!%E2%80%B9%28%3A%E2%85%9B%E2%88%87%2B%29%C2%BE&inputs=%5B1%2C%202%2C%203%5D&header=&footer=): `÷^!‹(:⅛∇+)¾`
Also, look ma, no letters (and flags)! Funnily enough, I don't think there's any flag combination that would get this under 8 bytes.
## Explained
```
÷^!‹(…∇+
÷        # Push every item of the input onto the stack
 ^       # and reverse the stack to make the list indicative of the stack (Ṙ÷ achieves the same thing, but we're going 100% symbolic)
  !‹     # Push len(stack) - 1
    (    # and that many times:
     …   #    print the top of the stack without popping
      ∇  #    perform rot. Fun fact: I added rot to vyxal after seeing forth/factor as LoTM
       + #    add the top two items
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~61~~ ~~58~~ 57 bytes
```
lambda a:[a[~i%2]+sum(a[i:1:-2])for i in range(1,len(a))]
```
[Try it online!](https://tio.run/##bYrBCsIwEETP@hVLQUhwc0haaw3oj8QcVmx1oU1LrQcv/npMFXryMMw83gyv6d6HPDbHc2ypu1wJyDpyb94Yv308O0GOrbbKeNn0IzBwgJHCrRYa2zoIktLHxTinEQxC7nFeKuVP/eR8QygQdgglwh6hQjgsrviyTiZPVCbUpvLerlfDyGESjBmoE2TYCJYyfgA "Python 3 – Try It Online")
-3 bytes thanks to @MarcMush
-1 byte thanks to @ovs, by shifting the range by 1
a is the original sequence and b is the -rot transform (both 0-based):
b is define like this :
`n` is even : `b(n) = a(0) + (sum of all odd terms from a(3) to a(n+1))`
`n` is odd : `b(n) = a(1) + (sum of all even terms from a(2) to a(n+1))`
[Answer]
# JavaScript, 42 bytes
Saved 4 bytes prior to posting by following [DLosc's lead](https://codegolf.stackexchange.com/a/233668/58974) and taking the input integers as individual arguments rather than as a single array.
```
f=(x,y,z,...a)=>[x,...1/z?f(y+z,x,...a):a]
```
[Try it online!](https://tio.run/##XY5NC4JAEIbv/QqPK75u7mpmhXbq0qEOHWXBxS8MU1EJ9c@bJhE1h@GZ552BucunbMI6q1q9KKN4HBOXdOgxgFIqVdfzu5nYejgmpNcGdEuwl2I8@CufgcMUmEFn@G2LnnJY2MDGFg52H2lNA7NhctgWGHcWb8y3Br4gVoI@ZEWk64Vl0ZR5TPMyJefb9UKbts6KNEt6IlVayehURIRzVQsU3VMC7W8nIe/Hpxpf)
Or, if outputting a comma delimited string with a trailing comma is allowed then:
# JavaScript, 40 bytes
```
f=(x,y,z,...a)=>x+[,1/z?f(y+z,x,...a):a]
```
[Try it online!](https://tio.run/##VY7NCoJAAITvPoXHXRw3dzWzQjt16VCHjiK4@IdhKiqhvrxpEtFlmPmGgXnIl2yjJq87vaziZJpSl/QYMIIxJqnr9ZoPvhlPKRm0Ef2KDzKYjr7icwiYARajc/zLiuceFrawsYOD/Rdac@A2TAHbAhfOyo1la@BnAiVgT1kT6XpRVbZVkbCiysjlfruytmvyMsvTgUjKahmfy5gIQbVQ1T011FLyeUrp9AY)
[Answer]
## [Perl 5](https://www.perl.org/), ~~57~~ 56 + 4 (`-apl` options) = 60 bytes
```
$F[$_-1]+=$F[$_],$F[$_]=$F[$_-2]for 2..$#F;pop@F;$_="@F"
```
[Try it online!](https://tio.run/##VYtBCoMwFET3OcVgs2sj/hhTRQRXuUQJ0kULBWk@tuf318ZF6WbmzQzDt2VuRHS46MlQPA6Z4mm3PRkb72mBLUt9CD0nHkOvp6EYQyFCsKgVwRD@ReUFDg08zmjR5cZtRB61hXcg225l9b1U@IFaE78f6fkSc@X5Aw "Perl 5 – Try It Online")
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~44~~ 39 bytes
```
f(*a,l){for(;--l;a[1]=*a++)a[1]+=a[2];}
```
[Try it online!](https://tio.run/##rVPLrpswEN3frxgh5YqHUXmmSWnaRdWvICwQMbeoDokCUqNG/Hrp2AZscyN1UxQyHp8znscxlV@xsn0bx9p2S8KcR3252Znvs6zMw@Lglp7n8JV3KPOoyIaxaXs4l01rO/B4AXz4Rk@7PswLOMAjJBARiIdsAaIF8PF9YjRubBxCICGQEtgS@EhgR2CvUROdmgg4RGKM3hbdMNpp5HQhBzJxIHJrjiS7gt1JtuiKyB6kiaVJpEmHzJgAk2Fd85tealtEOx8mz5UuAQ2NTDQy0dhEYxNNTDQx0dREU0erlN6vtOrpSemVToOakUgfVrBohTPwoxVV6ZWKX8jpXFfUK9xjzHYVoFRDrTiBi4febsvl26/Y6frqBPrNCWbNZrpkLw0S1ZFaxmqZqKUmpQvVD1r9pDd5mnW8f4@O9/03fFOLgO7H1hSGHw3YvPCmPdE7hgXZtPw8yzJnUsosOxl4nmDPn9RSyRmPkhdS4EWmw8AmlD1D8SYjXJWMXSqbkcRR6PWGeG1buaVtqham8rF0JirTq@JPnzd8Mmc0mQHM5266zQkn1Xzl4/pk4T8P0XIN70opwP8CZj12T4A5q54oJl7UfjaTa9l1yAn/0Rj4SHnW3BQvzOvr1Cvm/L/Nbrpji8z5ovFsekh9o9Tup43hZRj/VDUr37rR//UX "C (clang) – Try It Online")
Saved 5 bytes thanks to [AZTECCO](https://codegolf.stackexchange.com/users/84844/aztecco)!!!
Inputs a pointer to a finite sequence of integers and its length (since pointers in C carry no length info), and computes its -rot transform in place.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 40 bytes
```
\d+
$*
+1`(1*),(1*,)(1*)
$1¶$3$2$1
%`\G1
```
[Try it online!](https://tio.run/##HcixDYAgFITh/s3xSASueYCoE1i5gQUmWthYGGdzABZDpPnvy93Hc15bKetuiQ1ZSZ0YjRroX8SSX/bsWEildZZSd/lBSiem/BaBg6dWBPSIGDBiak@okgjvEAPEjR8 "Retina 0.8.2 – Try It Online") Link includes footer that spaces the results out. Takes input as a comma-separated list of non-negative integers due to limitations of unary, and outputs a newline-separated list (+4 bytes for newline-separated input or +5 bytes for comma-separated output). Explanation:
```
\d+
$*
```
Convert to unary.
```
+1`(1*),(1*,)(1*)
$1¶$3$2$1
```
Make a copy of the first number, then rotate it below the sum of the third and second numbers. Repeat until there are only two numbers left.
```
%`\G1
```
Convert the first number on each line to decimal. This outputs the initial first number and all of the copied sums, but avoids duplicating the penultimate sum.
[Answer]
# [tinylisp](https://github.com/dloscutoff/Esolangs/tree/master/tinylisp), 75 bytes
```
(d F(q((S)(c(h S)(i(t(t S))(F(c(a(h(t S))(h(t(t S))))(c(h S)(t(t(t S))))))(
```
Defines a function `F` that takes a list and returns a list. [Try it online!](https://tio.run/##RY7BCsIwEETvfsUcZw@CVUH8gR69@AXbptpA2sQalH59XLDa08483sBmP87BP1MpdKj5IK/Clj3seGZmC8LakLJfWv/j8lfzigwWhqgOwTeTTrNsWINVjjjIN99icAFtHFvN4NSlTvP2pQG0VzIqcOzuqERwFFnn5yUPmszUoXEKXgRM8Y09LuZzZ97JRuUD "tinylisp – Try It Online")
### Explanation
Pretty straightforward, once you fight your way through all the parentheses:
```
(d F                      ; Define F
 (q                       ; to be a list representing a function
  ((S)                    ; that takes one argument, S:
   (c                     ;  Cons
    (h S)                 ;  the first element of S to the following list:
    (i (t (t S))          ;   If the tail of tail of S is not empty:
     (F                   ;    Call F recursively, with an argument of
      (c                  ;    cons...
       (a                 ;     the result of adding
        (h (t S))         ;     the second element of S and
        (h (t (t S))))    ;     the third element of S
       (c                 ;    ... to the cons of...
        (h S)             ;     the first element of S and
        (t (t (t S))))))  ;     S without its first three elements
     ()                   ;   Else, empty list
```
---
The same thing (but snazzier and less golfy) is **92 bytes** in tinylisp's descendant language [Appleseed](https://github.com/dloscutoff/appleseed):
```
(def F(q((S)(cons(head S)(if(ttail S)(F(cons(sum(take 2(tail S)))(cons(head S)(drop 3 S))))(
```
[Try it online!](https://tio.run/##XY5BcsIwDEX3PcXvTt4lsKCs2OUCPYFqC@rBid1IlOH0wSFkmGEly@/rSVxKEhUJ00RBjujoj@jbkc@D0q9wQG3ikcw4pvndLUgvPRmfBRt6Evc2FMZcsH0AR4vcRM2zioJSVAO1lrF1WExfIH/zSZ6wBQ1yQjvPL8l9rT0XUOHRIieUfMUGh/rdVLxzq2n/bmpWF5pZ5z4e56hVz2cNcf8TGCT/Mti6w@e@ZBWUMQ411LnX9VUw3QE "Appleseed – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 34 bytes
```
f(a:b:c:d)=a:f(b+c:a:d);f(a:_)=[a]
```
[Try it online!](https://tio.run/##FchJDkBAEAXQq9TCosXfmCnpk4hImTuGCO5fWL63yL2O26Y6GeGOex58KzyZLuhZPlT/t76tpdFd3GHPyx2PN9chKALFoASUgjJQDipAZaMv "Haskell – Try It Online")
This takes the straight forward approach. All the other fancy approaches just don't really end up saving any bytes in Haskell.
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~47 38~~ 34 bytes
```
->a,b,*l{l.map{|x|a,b=b+x,a;b}<<a}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y5RJ0lHK6c6Ry83saC6pqIGyLdN0q7QSbROqrWxSaz9X6CQFm2oY6RjrGOiY6pjpmOuY6FjGfsfAA "Ruby – Try It Online")
Variadic function accepting at least 2 parameters.
[Answer]
# [jq](https://stedolan.github.io/jq/), 53 bytes
```
[while(.[1];.[1]+=.[2]|(.[2]//.[0])=.[0]|.[1:])|.[0]]
```
[Try it online!](https://tio.run/##yyr8/z@6PCMzJ1VDL9ow1hpEaNvqRRvF1miASH19vWiDWE1bEFkDlLSK1awBsWOB2gx1FIx0FIxjuUAsXSDGQkEkQcp0FEx0FEx1FMx0FMx1FCx0FCzhciZgviFQxhjIMwNyDY0sILIGELMMwMYhcWL/5ReUZObnFf/XTQYA "jq – Try It Online")
**Explanation:**
```
Based on example input: [1, 2, 3]
[
    while(                  While
        .[1]                the array has at least two items
    ;
        .[1]+=.[2]          add the second and third number and store them on second position.
        |(.[2]//.[0])       Choose third element if it is not null else first element
            =.[0]           and set its value to the value of the first number.
        |.[1:]              Drop the first element.
    )
    |                       Now we have the evolution of the updated array, e.g. [[1,2,3],[5,1]]
    .[0]                    take the first element of each array
]                           [1,5]
```
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 50 bytes
```
{⎕←1↑⍵⋄({(3↓⍵),⍨(+/2↑1⌽3↑⍵),1↑⍵}⍣{⎕←1↑⍺⋄(⍴⍺)<3})⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHf1EdtEwwftU181Lv1UXeLRrWG8aO2yUCOps6j3hUa2vpGQDnDRz17jSFqNHWgimsf9S5G0b4LpP1R7xYgS9PGuFYTpOb/fwA "APL (Dyalog Classic) – Try It Online")
Explanation:
```
(+/2↑1⌽3↑⍵),1↑⍵ take the first three elements, rotate them, sum the first two and stick the third (which was originally the first element) on the end again so (a b c) -> (b c a) -> (b+c a)
(3↓⍵),⍨ concatenate this with the rest of the list
⍣{⎕←1↑⍺⋄(⍴⍺)<3} the above gets run until the list is less than 3 elements
```
Note: locally this seems to iterate one more time, but in tio.run it does not, unsure why. This is my first code golf attempt so certainly a lot to be improved on! Happy to hear from APL experienced users how this could be better, I dont like my use of ⎕ in this solution
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 16 bytes
```
ḣ2S;ɗḢṄ$ḷ"ƊḊḊ$¿Ḣ
```
[Try it online!](https://tio.run/##y0rNyan8///hjsVGwdYnpz/csejhzhaVhzu2Kx3rergDhFQO7QeK/v//P9pQR8FAR0EXQqFyYgE "Jelly – Try It Online")
Blegh. Full program, outputs each on a separate line
## How it works
```
ḣ2S;ɗḢṄ$ḷ"ƊḊḊ$¿Ḣ - Main link. Takes a list L on the left
              ¿  - While:
             $   -   Condition:
           ḊḊ    -     The list is non-empty after dequeuing twice
          Ɗ      -   Body:
       $        -     Last 2 links as a monad f(L):
     Ḣ          -       First element, X
      Ṅ         -       Print and return
    ɗ           -     Last 3 links as a dyad f(L[1:], X):
ḣ2              -       First 2 elements
  S             -       Sum
   ;            -       Concat with X
        ḷ"      -     Replace the first 2 elements of L with this pair
              Ḣ - Get the first element of the final pair
```
[Answer]
# [Keg](https://github.com/JonoCode9374/Keg), 16 bytes
```
÷^(!;|④
,&""&''+
```
[Try it online!](https://tio.run/##y05N////8PY4DUXrmkcTF3PpqCkpqamra///H22oo2Cko2Cso2Cio2Cqo2Cmo2Cuo2Cho2AZCwA "Keg – Try It Online")
## Explained
```
÷^     # Push all items of the input onto the stack and reverse the stack
(!;|   # len(stack) - 1 times:
④      #     print the top of the stack without popping
,      #     and print a newline too
&""&'' #     perform rot
+      #     and add the top two items
```
[Answer]
# [Julia 1.0](http://julialang.org/), 37 bytes
```
a\b=a
\(a,b,c,r...)=[a;\(b+c,a,r...)]
```
Inspired by [DLosc's answer](https://codegolf.stackexchange.com/a/233668/98541)
the numbers are taken as separate arguments, and Julia's multiple dispatch makes it really easy to separate between 2 arguments (first method) and 3 or more arguments (second method)
[Try it online!](https://tio.run/##bY7BCoMwEETv@Yo5RroVo9ZaSvojSQ7RWrBIWjSF/n0aFcFDF5bd2bcM8/wMvRXfEKxupGWaW2qopTFN00Qqe9W8ObRk14MJvpv8BAnFoAQhJxSG1v0Y@8/Y8PxKKAknQkU4E2rCZUfL5SIiK6KqohR5vfFsdcwW050wzDD2eI3w6B2WdAyx3mPv/OC4h7xBcz@nT1jn7uEH "Julia 1.0 – Try It Online")
[Answer]
# Scala, 66 bytes
```
s=>Seq.iterate(s,s.size-1)(s=>s(1)+s(2)::s(0)::s.drop(3))map(_(0))
```
[Try it in Scastie!](https://scastie.scala-lang.org/FPvh9EZTT2eEUvdcrZBqqg)
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 8 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
å+
j1
ån
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=5SsKajEK5W4&input=WzEgMiAzIDQgNSA2IDcgOCA5XQ)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~31~~ ~~25~~ 22 bytes
```
≔ΦＥθΣ…θ⊕κ⊖κθＩＥθ↨…θ⊕κ±¹
```
[Try it online!](https://tio.run/##fcw9C8IwEIDh3V9x4wXOoX5LJ60IDorgWDoc8WiDaWqTKPjr4wc4uPiO7/Dohr3u2Ka0CsHUDrfGRvG45yv2BKdbi8VDWyma7jN2TntpxUU540W9ItjIzyLoVT44euMiFhzil1pzkL8WwUFqjoLZ21V5SmWZEYwIxgQTginBjGBOsCBYVlUa3u0T "Charcoal – Try It Online") Link is to verbose version of code. Explanation: Now a port of @Lynn's Jelly answer.
```
≔ΦＥθΣ…θ⊕κ⊖κθ
```
Calculate the cumulative sums of the input, i.e. the sums of all of its nontrivial prefixes, but then remove the second sum.
```
ＩＥθ↨…θ⊕κ±¹
```
Calculate their cumulative differences, which is done by interpreting their nontrivial prefixes in base `-1`.
[Answer]
# [BQN](https://mlochbaum.github.io/BQN/), 9 bytes[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)
```
-˜`⊑∾2↓+`
```
[Try it here.](https://mlochbaum.github.io/BQN/try.html#code=RiDihpAgLcucYOKKkeKIvjLihpMrYAoKRsKo4p+oMeKAvzLigL8zLCAx4oC/wq8x4oC/MeKAv8KvMeKAvzHigL/CrzHigL8x4oC/wq8xLCAx4oC/MuKAvzPigL804oC/NeKAvzbigL834oC/OOKAvzksIDHigL8y4oC/NOKAvzjigL8xNuKAvzMy4oC/NjTigL8xMjgsIDHigL8w4oC/wq8x4oC/MOKAvzHigL8w4oC/wq8x4oC/MOKAvzHin6k=)
Based on [Lynn's solution](https://codegolf.stackexchange.com/a/233671/74681).
```
-˜`⊑∾2↓+`
     2↓+` # drop 2 elements from the plus scan
    ∾     # joined to
   ⊑      # first element of input
-˜`       # swapped subtraction scan
```
[Answer]
# C++14 (or newer), 81 bytes
```
[](auto&v){for(int i=1,t;++i<v.size();v[i]=t)t=v[i-2],v[i-1]+=v[i];v.pop_back();}
```
A [lambda function](https://en.cppreference.com/w/cpp/language/lambda) that modifies the passed [`std::vector`](https://en.cppreference.com/w/cpp/container/vector) by reference.
Tests: <https://coliru.stacked-crooked.com/a/759a69be8a6398f1>
[Answer]
# [Perl 5](https://www.perl.org/), 54 bytes
```
sub f{my($a,$b,$c,@r)=@_;($a,@r?f($b+$c,$a,@r):$b+$c)}
```
[Try it online!](https://tio.run/##fZDBToNAFEX3fMVNQzJDfU2AtlhKsOxN7MadEiOGKtpSpBhtmm79AN326/oj@GZaCTGNZJjJfXPPfTNTpOV8WNertwSzzWItzXsyEzIfKCqtMLoLVCEqJzNpJmdc1coaa2Ft68U6qtJVFUoDuHEILqEf49QXXmjDMKajtcf/iSVurLYexz0O7rkNq9oQBhxH8AjnhBHBj1tt9HAUr4LZ4PiMee2EgaYc5vusPJaOO4p/E7isCOVjNfKU029w@3Cqw/laosGP97Hbl7MZtwLj/Smbp1KaWV6QmX4UpJ@QH1svG@6wWCN6XFbhTEbKxQxQlFle4XmZ5VKQILVvIX1tVVSWhQnE8gX73TcgMIbodrtX02tMLyFOxeh8Yiuw//ziWdCfJoTObd4JjG1d/3vzHw "Perl 5 – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 65 bytes
```
l=input();print l[0]
while l[2:]:k=l[1]+l[2];print k;l[:3]=k,l[0]
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P8c2M6@gtERD07qgKDOvRCEn2iCWqzwjMycVyDSyirXKts2JNozVBnJioUqyrXOirYxjbbN1QIr//4821DHSMdYx0THVMdMx17HQsYwFAA "Python 2 – Try It Online")
-17 thanks to @ovs
-3 from me on ovs improvement
[Answer]
# [J](http://jsoftware.com/), 16 bytes
```
1{1-/\.&.|.\.+/\
```
[Try it online!](https://tio.run/##y/r/P81WT8Gw2lBXP0ZPTa9GL0ZPWz/mf2pyRr5CmoKhgpGCMRcyR8FEwVTBTMFcwULBEiERb4hGIOsxAao1NFMwNlIwM1EwNLL4DwA "J – Try It Online")
Translated from [Lynn’s Jelly solution](https://codegolf.stackexchange.com/a/233671/74681)
[Answer]
# [Zsh](https://zsh.sourceforge.io/), ~~72~~ 50 bytes
```
for _ ({2..$#}){printf $1\ ;2=$[$3+$2];3=$1;shift}
```
Used shell parameters instead of variables, saved 22 bytes!
[try it online!](https://tio.run/##XYzBCoMwGIPvfYrg/kNlKLbVziEde485dhgr9aJDPa302TuVMcYuyUdC8ppctDz17HF3A7IeCadzinaGMafFkmiHETdwL/OcdiH1z7HrZwsSLRpp6EJqT/LaKEOimVxn5xDXLxaYhYCEwgaZ@JNvXaKCxgE1jp@sXFhoKAldQsh6i4t1WPxAfAM)
 
~~[72 bytes](https://tio.run/##XY3RCoIwGIXv9xQH2YUSgptmhix6jzm6CIcGm6HrJvHZl7OI6OY/H9/h8D@nzus4mcnDTq1DjxsMLGmv3YDUIorpOUHjIMRpjcgbEUw9db12RA8jLvV8H3vrNKiRTDUgRnIlqDQyV7vAqg4otvo9hFl8@EAWosHAkWODlP2db11gjxIHVDh@XLEyK5FzlAUYrzadhWH2A/4F)~~
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 10 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
R`[=.g<#Š+
```
[Try it online](https://tio.run/##yy9OTMpM/f8/KCHaVi/dRvnoAu3//6MNdRSMdBSMdRRMdBRMdRTMdBTMdRQsdBQsYwE) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5JlXUFpipaBkX6mj5F9aAuHoVP4PSoi21Uu3UT66QPt/7aFt9pox/6OjDXWMdIxjdYC0rqEOKgEWBcrqmOiY6pjpmOtY6FhCxUyAbEMzHWMjHTMTHUMjC7CwAUijgQ6CERsLAA).
A port of [*@Lynn*'s top Jelly answer](https://codegolf.stackexchange.com/a/233671/52210) is **10 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)** as well:
```
ηO¯1ǝ˜Å»s-
```
[Try it online](https://tio.run/##ATUAyv9vc2FiaWX//863T8KvMcedy5zDhcK7cy3//1sxLCAyLCAzLCA0LCA1LCA2LCA3LCA4LCA5XQ) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/c9v9D603PD739JzDrYd2F@v@r9X5Hx1tqGOkYxyrA6R1DXVQCbAoUFbHRMdUx0zHXMdCxxIqZgJkG5rpGBvpmJnoGBpZgIUNQBoNdBCM2FgA).
**Explanation:**
```
R           # Reverse the (implicit) input-list
 `          # Pop and dump all items separated to the stack
  [         # Start an infinite loop:
   =        #  Print the top item with trailing newline (without popping)
    .g      #  Get the amount of items on the stack
      <     #  If this is 2:
       #    #   Stop the infinite loop
    Š       #  Triple swap the top three items (a,b,c to c,a,b)
     +      #  Add the top two items together
η           # Get the prefixes of the (implicit) input-list
 O          # Sum each inner prefix together
            # Remove the second item by:
  ¯1ǝ       #  Replacing the second item (at index 1) with an empty list
     ˜      #  And then flatten the list of lists
      Å»    # Cumulative left-reduce the list by:
        s   #  Swapping the two items
         -  #  And subtracting them from one another
            # (after which the list is output implicitly as result)
```
[Answer]
# [Whitespace](https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.php), 58 bytes (12 bytes in Binary Whitespace)
```
LSSTLSLSTLSTSSLSLTTTSLSSLTSSSSLSTLSTSSLTTTSLTSSLSLTTTSLSLL
```
where S is space (ASCII 32), T is tab (ASCII 9), and L is line feed (ASCII 10).
Whitespace is a stack-based language, which would seem ideal for this challenge, however it provides very limited stack instructions—none of which can modify the stack below the top two elements. The heap can be used as scratch space though. For this challenge, only one heap address is needed, which we'll call the accumulator `acc` in the pseudocode.
The program ends once the stack underflows. Label `1` is not necessary, but it makes the program a callable procedure to follow [Code Golf rules](https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet/2422#2422).
Formatted as readable Whitespace Assembly:
```
1:                  # LSSTL
    dup printi      # SLS TLST
    0 swap store    # SSL SLT TTS
_:                  # LSSL
    + dup printi    # TSSS SLS TLST
    0 retrieve swap # SSL TTT SLT
    0 swap store    # SSL SLT TTS
    jmp _           # LSLL
```
Notes on syntax:
* `_` represents a label with no digits. It is unique from label `0`.
* A raw digit literal represents a `push` instruction.
Pseudocode:
```
func f(stack) {
  print(stack.top())
  var acc = stack.pop()  # heap address 0
  loop {
    var x = stack.pop() + stack.pop()
    print(x)
    acc, x = x, acc
    stack.push(x)
  }
}
```
## Binary Whitespace, 12 bytes
Whitespace has a trinary alphabet (space, tab, LF), but it can be represented with a binary alphabet with a simple mapping. Space becomes `0`, tab becomes `10`, and LF becomes `11`. All trailing zeros on the last byte are ignored. If the final character ends with `0` (i.e. space or tab), then append a `1` to the bit stream. This encoding is implemented by [Nebula](https://github.com/andrewarchi/nebula).
If other code golf languages can pick arbitrary encodings, then this should be fair :).
```
11000110 11010110 10001101 11010100
11001110 00001101 01101000 11101010
01110001 10111010 10011011 11000000
```
## Running
These are the five provided test cases. Run the program with one of these prefixed. Digits are outputted without delimiters to save bytes.
1. `SSSTTL SSSTSL SSSTL LSTTL`
2. `SSTTL SSSTL SSTTL SSSTL SSTTL SSSTL SSTTL SSSTL LSTTL`
3. `SSSTSSTL SSSTSSSL SSSTTTL SSSTTSL SSSTSTL SSSTSSL SSSTTL SSSTSL SSSTL LSTTL`
4. `SSSTSSSSSSSL SSSTSSSSSSL SSSTSSSSSL SSSTSSSSL SSSTSSSL SSSTSSL SSSTSL SSSTL LSTTL`
5. `SSSTL SSL SSTTL SSL SSSTL SSL SSTTL SSL SSSTL LSTTL`
```
3 2 1                call 1  # => 15
-1 1 -1 1 -1 1 -1 1  call 1  # => 1001-12-2
9 8 7 6 5 4 3 2 1    call 1  # => 1551011171926
128 64 32 16 8 4 2 1 call 1  # => 169224186169
1 0 -1 0 1 0 -1 0 1  call 1  # => 1-1101-110
```
The interpreter must allow empty labels and argument literals. The reference interpreter [wspace](https://web.archive.org/web/20150717140342/http://compsoc.dur.ac.uk/whitespace/download.php) (and thus TIO) does not support this; [Nebula](https://github.com/andrewarchi/nebula) and [Whitelips](https://vii5ard.github.io/whitespace/) do.
]