[Question]
  [
Last time when I tried to come up with something easy that wasn't a duplicate, it ended up being way too hard.. So hopefully this time it's indeed something newcomers can try as well.
**Input:**
An array/list with integers/decimals. (Or a string representing an array with integers/decimals.)
**Output:**
Loop through the numbers and apply the following five mathematical operands in this order:
* Addition (`+`);
* Subtraction (`−`);
* Multiplication (`*` or `×` or `·`);
* *Real / Calculator* Division (`/` or `÷`);
* Exponentiation (`^` or `**`).
(NOTE: The symbols between parenthesis are just added as clarification. If your programming language uses a completely different symbol for the mathematical operation than the examples, then that is of course completely acceptable.)
Keep continuing until you've reached the end of the list, and then give the result of the sum.
**Challenge rules:**
* Exponentiation by 0 (`n ^ 0`) should result in 1 (this also applies to `0 ^ 0 = 1`).
* There are no test cases for division by 0 (`n / 0`), so you don't have to worry about that edge-case.
* If the array contains just a single number, we return that as the result.
**General rules:**
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins.  
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
* [Standard rules apply](https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet/2422#2422) for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.
* [Default Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* If possible, please add a link with a test for your code.
**Test cases:**
```
[1,2,3,4,5] -> 0
-> 1 + 2 = 3
  -> 3 - 3 = 0
    -> 0 * 4 = 0
      -> 0 / 5 = 0 
[5,12,23,2,4,4,2,6,7] -> 539
-> 5 + 12 = 17
  -> 17 - 23 = -6
    -> -6 * 2 = -12
      -> -12 / 4 = -3
        -> -3 ^ 4 = 81
          -> 81 + 2 = 83
            -> 83 - 6 = 77
              -> 77 * 7 -> 539
[-8,50,3,3,-123,4,17,99,13] -> -1055.356...
-> -8 + 50 = 42
  -> 42 - 3 = 39
    -> 39 * 3 = 117
      -> 117 / -123 = -0.9512...
        -> -0.9512... ^ 4 = 0.818...
          -> 0.818... + 17 = 17.818...
            -> 17.818... - 99 -> -81.181...
              -> -81.181... * 13 = -1055.356...
[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2] -> 256
-> 2 + 2 = 4
  -> 4 - 2 = 2
    -> 2 * 2 = 4
      -> 4 / 2 = 2
        -> 2 ^ 2 = 4
          -> 4 + 2 = 6
            -> 6 - 2 = 4
              -> 4 * 2 = 8
                -> 8 / 2 = 4
                  -> 4 ^ 2 = 16
                    -> 16 + 2 = 18
                      -> 18 - 2 = 16
                        -> 16 * 2 = 32
                          -> 32 / 2 = 16
                            -> 16 ^ 2 = 256
[1,0,1,0,1,0] -> 1
-> 1 + 0 = 1
  -> 1 - 1 = 0
    -> 0 * 0 = 0
      -> 0 / 1 = 0
        -> 0 ^ 0 = 1
[-9,-8,-1] -> -16
  -> -9 + -8 = -17
    -> -17 - -1 = -16
[0,-3] -> -3
  -> 0 + -3 = -3
[-99] -> -99
```
  
[Answer]
# Javascript ES7 49 bytes
```
a=>a.reduce((c,d,e)=>[c**d,c+d,c-d,c*d,c/d][e%5])
```
Saved 9 bytes thanks to Dom Hastings, saved another 6 thanks to Leaky Nun
Uses the new exponentiation operator.
[Answer]
# Haskell, ~~76~~ ~~65~~ ~~64~~ 62 bytes
Thanks to @Damien for removing another two bytes=)
```
f(u:v)=foldl(\x(f,y)->f x y)u(zip(v>>[(+),(-),(*),(/),(**)])v)
```
This uses the `>>` which here just appends the list `[(+),...]` to itself `length v` times. The rest still works still the same as the old versions.
Old versions:
These solutions make use of the infinite lists, as `cycle[...]` just repeats the given list infinitely. Then it basically gets `zip`ed with the list of numbers, and we just `fold` (*reduce* in other languages) the zipped list via a lambda, that applies the operators to the accumulator/current list element.
```
f(u:v)=foldl(\x(f,y)->f x y)u(zip(cycle[(+),(-),(*),(/),(**)])v)
f(u:v)=foldl(\x(y,f)->f x y)u(zip v(cycle[(+),(-),(*),(/),(**)]))
f l=foldl(\x(y,f)->f x y)(head l)(zip(drop 1l)(cycle[(+),(-),(*),(/),(**)]))
```
[Answer]
## Pyke, ~~22~~ 21 bytes
```
lt5L%"+-*/^"L@\RJQ_XE
```
[Try it here!](http://pyke.catbus.co.uk/?code=lt5L%25%22%2B-%2a%2F%5E%22L%40%5CRJQ_XE&input=%5B-8%2C50%2C3%2C3%2C-123%2C4%2C17%2C99%2C13%5D)
```
lt5L%                 -    map(len(input)-1, %5)
     "+-*/^"L@        -   map(^, "+-*/^"[<])
              \RJ     -  "R".join(^)
                    E - pyke_eval(^, V)
                 Q_X  -  splat(reversed(input))
```
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), 13 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
“+_×÷*”ṁṖ⁸żFV
```
[Try it online!](http://jelly.tryitonline.net/#code=4oCcK1_Dl8O3KuKAneG5geG5luKBuMW8RlY&input=&args=Wy04LDUwLDMsMywtMTIzLDQsMTcsOTksMTNd) or [verify all test cases](http://jelly.tryitonline.net/#code=4oCcK1_Dl8O3KuKAneG5geG5luKBuMW8RlYKw4figqw&input=&args=WzEsMiwzLDQsNV0sIFs1LDEyLDIzLDIsNCw0LDIsNiw3XSwgWy04LDUwLDMsMywtMTIzLDQsMTcsOTksMTNdLCBbMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMl0sIFsxLDAsMSwwLDEsMF0sIFstOSwtOCwtMV0sIFswLC0zXSwgWy05OV0).
### How it works
```
“+_×÷*”ṁṖ⁸żFV  Main link. Argument: A (list of integers)
“+_×÷*”        Yield the list of operations as a string.
        Ṗ      Yield A popped, i.e., with its last element removed.
       ṁ       Mold; reshape the string as popped A.
               This repeats the characters of the string until it contains
               length(A)-1 characters.
         ⁸ż    Zipwith; pairs the integers of A with the corresponding characters.
           F   Flatten the result.
            V  Eval the resulting Jelly code.
               Jelly always evaluates left-to-right (with blatant disregard towards
               the order of operations), so this returns the desired result.
```
[Answer]
# Haskell, 61 Bytes
```
foldl(flip id)0.zipWith flip((+):cycle[(+),(-),(*),(/),(**)])
```
Creates a series of transformations in a list, as in [add 1, add 2, subtract 3, ...], starting with 2 additions because we start with 0 in the fold. Next, we do what I call the List Application Fold, or foldl (flip id), which applies a list of homomorphisms in series. This starts with zero, adds the initial value, then does all of the above computed transformations to get a final result.
Note that (flip id) is the same as (\x y->y x), just shorter.
Sample usage:
```
f = foldl(flip id)0.zipWith flip((+):cycle[(+),(-),(*),(/),(**)])
f [1,2,3,4,5] -- Is 0.0
```
[Answer]
# TSQL ~~116~~ ~~115~~ 88 bytes
Thanks to Ross Presser suggestion I was able to golf this down to 88 characters
```
-- In Try-it code, this must be DECLARE @y TABLE 
CREATE TABLE T(a real, i int identity)
INSERT T values(5),(12),(23),(2),(4),(4),(2),(6),(7)
DECLARE @ REAL SELECT @=CHOOSE(i%5+1,@/a,ISNULL(POWER(@,a),a),@+a,@-a,@*a)FROM T
PRINT @
```
[Try it online](https://data.stackexchange.com/stackoverflow/query/1064531/weapons-of-math-instruction)
[Answer]
# Pyth, ~~27~~ ~~26~~ 25 bytes
```
.v+>tlQ*lQ"^c*-+":jdQ\-\_
```
[Test suite.](http://pyth.herokuapp.com/?code=.v%2B%3EtlQ%2alQ%22%5Ec%2a-%2B%22%3AjdQ%5C-%5C_&test_suite=1&test_suite_input=%5B1%2C2%2C3%2C4%2C5%5D%0A%5B5%2C12%2C23%2C2%2C4%2C4%2C2%2C6%2C7%5D%0A%5B-8%2C50%2C3%2C3%2C-123%2C4%2C17%2C99%2C13%5D%0A%5B2%2C2%2C2%2C2%2C2%2C2%2C2%2C2%2C2%2C2%2C2%2C2%2C2%2C2%2C2%2C2%5D%0A%5B1%2C0%2C1%2C0%2C1%2C0%5D%0A%5B-9%2C-8%2C-1%5D%0A%5B0%2C-3%5D%0A%5B-99%5D&debug=0)
Pyth uses prefix notation: `1+2` is written as `+1 2` (space needed to separate numbers).
Therefore, for the first testcase, the expression would be `(((1+2)-3)*4)/5`, which in prefix notation, would be written as `/*-+ 1 2 3 4 5`.
In Pyth, float division is `c` instead of `/`, so it becomes `c*-+ 1 2 3 4 5`.
Also, in Pyth, `-100` is written as `_100` instead.
Therefore, for the third test case, which is `((((((((-8+50)-3)*3)/-123)^4)+17)-99)*13)`, it becomes: `*-+^c*-+ _8 50 3 3 _123 4 17 99 13`.
```
.v+>tlQ*lQ"^c*-+":jdQ\-\_
                  jdQ       Join input by space.
                 :   \-\_   Replace "-" with "_".
   >tlQ*lQ"^c*-+"           Generate the string "...^c*-+" of suitable length.
  +                         Join the two strings above.
.v                          Evaluate as a Pyth expression.
```
## History
* 33 bytes: [`v:P+*lQ\(ssV+R\)Q*"+-*/p"lQ\p"**"`](https://codegolf.stackexchange.com/revisions/82774/1)
* 27 bytes: [`.vs+_XUtQUQ"+-*c^"m:+;d\-\_`](https://codegolf.stackexchange.com/revisions/82774/2)
* 26 bytes: [`.vs+_XUtQUQ"+-*c^":jdQ\-\_`](https://codegolf.stackexchange.com/revisions/82774/4)
[Answer]
## Actually, 23 bytes
```
;l"+-*/ⁿ"*@R':j':+'?o+ƒ
```
[Try it online!](http://actually.tryitonline.net/#code=O2wiKy0qL-KBvyIqQFInOmonOisnP28rxpI&input=MSwyLDMsNCw1)
Actually uses postfix notation for mathematics, and operators that only ever take two arguments (such as the operators for addition, subtraction, multiplication, division, and exponentiation) do nothing when there is only one element on the stack. Thus, turning the input into Actually code is as simple as reversing the input, formatting it as numerics, and appending the operations. Then, the resultant code can be executed, giving the desired output.
## Explanation:
```
;l"+-*/ⁿ"*@R':j':+'?o+ƒ
;l"+-*/ⁿ"*               repeat the operations a number of times equal to the length of the input
                            (since extraneous operations will be NOPs, there's no harm in overshooting)
          @R             reverse the input
            ':j          join on ":" (make a string, inserting ":" between every pair of elements in the list)
               ':+       prepend a ":" (for the first numeric literal)
                  '?o    append a "?"
                           (this keeps the poor numeric parsing from trying to gobble up the first + as part of the numeric literal, since ? isn't interpreted as part of the literal, and is a NOP)
                     +   append the operations string
                      ƒ  cast as a function and call it
```
Example of translated code for input `1,2,3,4,5`:
```
:5:4:3:2:1?+-*/ⁿ+-*/ⁿ+-*/ⁿ+-*/ⁿ+-*/ⁿ
```
[Answer]
# Julia, ~~53~~ 50 bytes
```
!x=(i=0;foldl((a,b)->(+,-,*,/,^)[i=i%5+1](a,b),x))
```
[Try it online!](http://julia.tryitonline.net/#code=IXg9KGk9MDtmb2xkbCgoYSxiKS0-KCssLSwqLC8sXilbaT1pJTUrMV0oYSxiKSx4KSkKCmZvciB4IGluIChbMSwyLDMsNCw1XSwgWzUsMTIsMjMsMiw0LDQsMiw2LDddLCBbLTgsNTAsMywzLC0xMjMsNCwxNyw5OSwxM10sIFsyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyXSwgWzEsMCwxLDAsMSwwXSwgWy05LC04LC0xXSwgWzAsLTNdLCBbLTk5XSkKICAgIEBwcmludGYoIiUtMzNzIC0-ICVnXG4iLHgsIXgpCmVuZA&input=)
[Answer]
# J, 40 bytes
```
^~`(%~)`*`(-~)`+/@(|.@,7#:~#&2)(5-5|4+#)
```
Finds the number of values needed to use a multiple of 5 operators, than pads with the identity values of those operators. In order, `+` is 0, `-` is 0, `*` is 1, `%` is 1, and `^` is 1, which can be a bit value `00111`, or 7 in base 10. Then operates on that list while cycling through operators.
## Usage
```
   f =: ^~`(%~)`*`(-~)`+/@(|.@,7#:~#&2)(5-5|4+#)
   f 1 2 3 4 5
0
   f 5 12 23 2 4 4 2 6 7
539
   f _8 50 3 3 _123 4 17 99 13
_1055.36
   f 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
256
   f 1 0 1 0 1 0
1
   f _9 _8 _1
_16
   f 0 _3
_3
   f _99
_99
```
## Explanation
```
^~`(%~)`*`(-~)`+/@(|.@,7#:~#&2)(5-5|4+#) Input: A
                                      #  Get length of A
                                    4+   Add four to it
                                  5|     Take it mod 5
                                5-       Find 5 minus its value, call it x
                           #&2           Create x copies of 2
                       7#:~              Convert 7 to base 2 and take the last x digits
                      ,                  Append those x digits to the end of A
                   |.@                   Reverse it, call it A'
^~                                       Power, reversed operators
    %~                                   Division, reversed operators
       *                                 Multiplication
         -~                              Subtraction, reversed operators
            +                            Addition
             /@                          Insert the previous operations, separated by `,
                                         into A' in order and cycle until the end
                                         Then evaluate the equation from right-to-left
                                         and return
```
[Answer]
# Python 2, ~~81~~ ~~67~~ 64 bytes
```
i=10
for n in input():exec'r%s=n'%'*+-*/*'[i::5];i=-~i%5
print r
```
Input is an array of floats. Test it on [Ideone](http://ideone.com/7HKWKV).
### How it works
`'*+-*/*'[i::5]` selects every fifth character of the string, starting with the one at index **i**, so this yields `**` if **i = 0**, `+` if **i = 1**, `-` if **i = 2**, `*` if **i = 3** and `/` if **i = 4**. Since the string has length **6**, the expression will yield an empty string if **i > 5**.
We initialize the variable **i** to **10**. For each number **n** in the input array, we construct the string `r<op>=n`, which `exec` executes. 
Initially, **i = 10**, so `<op>` is the empty string, and it initializes **r** with `r+=n`. After each step, we increment **i** modulo **5** with `i=-~i%5`, so the next step will retrieve the proper operator.
When all input numbers has been processed, and we print **r**, which holds the desired output.
[Answer]
# Matlab - 95 91 85 bytes / Octave - 81 bytes
Input is in such form: `a = ['1' '2' '3' '4' '5'];`, I hope this is covered by "string representing an array with integers/decimals", else there are 2 num2str needed additionally.
Every intermediate result gets printed to console because that saves me some semicolons. `a(1)` is executed so its value is then saved to `ans`. Also of course using `ans` in code is bad practice.
```
b='+-*/^'
a(1)
for i=2:length(a)
  ['(',ans,')',b(mod(i-2,5)+1),a(i)]
end
eval(ans)
```
In Octave, `'+-*/^'(mod(i+2,5)+1)` also works, which saves another 4 bytes, thanks Adám and Luis Mendo:
```
a(1)
for i=2:length(a)
  strcat('(',ans,')','+-*/^'(mod(i-2,5)+1),a(i))
end
eval(ans)
```
Changelog:
* Removed spaces where possible
* added Octave solution
* replaced strcat() with []
[Answer]
# Mathematica, ~~67~~ ~~66~~ 65 bytes
```
Fold[{+##,#-#2,#2#,#/#2,If[#2==0,1,#^#2]}[[i++~Mod~5+1]]&,i=0;#]&
```
Simple `Fold` with a variable `i` holding the index.
[Answer]
# CJam, 18 bytes
```
q~{"+-*/#"W):W=~}*
```
Input is an array of floats. [Try it online!](http://cjam.tryitonline.net/#code=cX57IistKi8jIlcpOlc9fn0q&input=Wy04LjAgNTAuMCAzLjAgMy4wIC0xMjMuMCA0LjAgMTcuMCA5OS4wIDEzLjBd)
### How it works
```
q~                  Read and evaluate all input.
  {             }*  Reduce:
   "+-*/#"            Push the string of operators.
          W           Push W (initially -1).
           ):W        Increment and save in W.
              =       Retrieve the character at that index.
               ~      Evaluate.
```
[Answer]
# [R](https://www.r-project.org/), ~~87 78~~ 70 bytes
```
i=0
Reduce(function(a,j)get(substr("+-*/^",i<<-i%%5+1,i))(a,j),scan())
```
[Try it online!](https://tio.run/##fU/bCsIwDH3vVxwsg9at2rRmczB/wg8QdE6pDxPc9v0zDnxUDgkhORfymjUhIGIHhoZXmkEBIcpyJwgoUcmBY62024O9cCMchY@EKtQ1KArBkWfeRK6UFvlfaAQuleR6fEuDxL6GJDha3IQge7dYR5mdBC19Tgevjt11ajtzm/p2TM/enIuHvXejGabLML7MKnfr7WlVpKZxKcs4pyJZu7CKoT33xtr55zPzGw "R – Try It Online")
[Answer]
## Haskell - 74
```
f(x:xs)=foldl(\x(o,y)->o x y)x(zip(cycle[(+),(-),(*),(/),flip(^).floor])xs)
```
Test cases:
```
λ> f[1,2,3,4,5] -> 0.0
λ> f[5,12,23,2,4,4,2,6,7] -> 539.0
λ> f[-8,50,3,3,-123,4,17,99,13] -> -1055.356943846277
λ> f [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2] -> 256.0
```
It could probably be shorter; Haskell's support for infinite lists and higher order functions make the direct solution quite pleasant, though. A version of `^ :: Double -> Double -> Double` would be nicer for golfing, but I couldn't find one. Thankfully, I didn't need a full lambda, so pointless style shaved off a few bytes.
[Answer]
## PowerShell v2+, 124 bytes
```
param($n)$o=$n[0];if($y=$n.count-1){1..$y|%{$o=if(($x=$i++%5)-4){"$o"+'+-*/'[$x]+$n[$_]|iex}else{[math]::pow($o,$n[$_])}}}$o
```
Long because PowerShell doesn't have a `^` or `**` operator, so we have to account for a separate case and use a .NET call.
Takes input `$n` as an array, sets our output `$o` to be the first digit. We then check the `.count` of the array, and so long as it's greater than one we enter the `if`. Otherwise, we skip the `if`.
Inside the `if` we loop through the array `1..$y|%{...}` and each iteration we re-set `$o` to a new value, the result of another `if/else` statement. So long as our counter `$i++` isn't modulo-5 equal to 4 (i.e., we're not at the `^` operator), we simply take `$o` and concatenate it with the appropriate symbol `'+-*/'[$x]` and the next number in the input array `$n[$_]`. We pipe that to `iex` (alias for `Invoke-Expression` and similar to `eval`), and that gets re-saved to `$o`. If we're on the `^` operator, we're in the `else`, so we execute a `[math]::Pow()` call, and *that* result gets re-saved back into `$o`.
In either case, we simply output `$o` to the pipeline and exit, with output implicit.
[Answer]
# Rust, 123, 117 bytes
Original answer:
```
fn a(v:&[f32])->f32{v.iter().skip(1).enumerate().fold(v[0],|s,(i,&x)|match i%5{0=>s+x,1=>s-x,2=>s*x,3=>s/x,_=>s.powf(x)})}
```
stupid long method names ^^
ahh much better
```
fn f(v:&[f32])->f32{v[1..].iter().zip(0..).fold(v[0],|s,(&x,i)|match i%5{0=>s+x,1=>s-x,2=>s*x,3=>s/x,_=>s.powf(x)})}
```
ungolfed
```
fn f(values : &[f32]) -> f32 {
    values[1..].iter().zip(0..)
    .fold(values[0], |state,(&x,i)|
        match i%5 {
            0=>state+x,
            1=>state-x,
            2=>state*x,
            3=>state/x,
            _=>state.powf(x)
        }
    )
}
```
[Answer]
# [Perl 6](http://perl6.org), ~~70 68 65~~ 62 bytes
```
~~{$/=[(|(&[+],&[-],&[\*],&[/],&[\*\*])xx\*)];.reduce: {$/.shift.($^a,$^b)}}
{(@\_ Z |(&[+],&[-],&[\*],&[/],&[\*\*])xx\*).flat.reduce: {&^b($^a,$^c)}}
{(@\_ Z |(\*+\*,\*-\*,&[\*],\*/\*,&[\*\*])xx\*).flat.reduce: {&^b($^a,$^c)}}~~
{reduce {&^b($^a,$^c)},flat @_ Z |(*+*,*-*,&[*],*/*,&[**])xx*}
```
### Explanation:
```
-> *@_ {
  reduce
    -> $a, &b, $c { b($a,$c) },
    flat       # flatten list produced from zip
      zip
        @_,    # input
        slip(  # causes the list of operators to flatten into the xx list
          # list of 5 infix operators
          &infix:<+>, &infix:<->, &infix:<*>, &infix:</>, &infix:<**>
        ) xx * # repeat the list of operators infinitely
}
```
Technically `* + *` is a Whatever lambda, but is effectively the same as `&[+]` which is short for `&infix:<+>` the set of subroutines that handle infix numeric addition.  
I didn't use that for multiplication or exponentiation as the ways to write them like that is at least as long as what I have (`*×*` or `* * *` and `* ** *`)
### Test:
Test it on [ideone.com](https://ideone.com/dRHzhx)  
(after they upgrade to a [Rakudo](https://rakudo.org) version that isn't from a year and a half before the official release of the [Perl 6](http://perl6.org) [spectests](https://github.com/perl6/roast "ROAST: Repository Of All Spec Tests"))
```
#! /usr/bin/env perl6
use v6.c;
use Test;
my @tests = (
  [1,2,3,4,5] => 0,
  [5,12,23,2,4,4,2,6,7] => 539,
  [-8,50,3,3,-123,4,17,99,13] => -1055.35694385, # -2982186493/2825761
  [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2] => 256,
  [1,0,1,0,1,0] => 1,
  [-9,-8,-1] => -16,
  [0,-3] => -3,
  [-99] => -99,
);
plan +@tests;
my &code = {reduce {&^b($^a,$^c)},flat @_ Z |(*+*,*-*,&[*],&[/],&[**])xx*}
for @tests -> $_ ( :key(@input), :value($expected) ) {
  is code(@input), $expected, .gist
}
```
```
1..8
ok 1 - [1 2 3 4 5] => 0
ok 2 - [5 12 23 2 4 4 2 6 7] => 539
ok 3 - [-8 50 3 3 -123 4 17 99 13] => -1055.35694385
ok 4 - [2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2] => 256
ok 5 - [1 0 1 0 1 0] => 1
ok 6 - [-9 -8 -1] => -16
ok 7 - [0 -3] => -3
ok 8 - [-99] => -99
```
[Answer]
# Python 3, ~~88~~ 93 bytes
```
f=lambda x:eval('('*(len(x)-1)+'){}'.join(map(str,x)).format(*['+','-','*','/','**']*len(x)))
```
It started off being much shorter but then operator precedence defeated me and I had to include lots of parenthesis...
[Answer]
# Oracle PL/SQL, ~~275~~ 254 Bytes
```
declare r number;begin for x in (select n,mod(rownum,5)r from t) loop if r is null then r:=x.n;elsif x.r=2then r:=r+x.n;elsif x.r=3then r:=r-x.n;elsif x.r=4then r:=r*x.n;elsif x.r=0then r:=r/x.n;else r:=r**x.n;end if;end loop;DBMS_OUTPUT.PUT_LINE(r);end;
```
The data must be inserted in a table called `T` with a column `N` of type `NUMBER`
Usage:
```
drop table t;
create table t (n number);
insert into t values (-8);
insert into t values (50);
insert into t values (3);
insert into t values (3);
insert into t values (-123);
insert into t values (4);
insert into t values (17);
insert into t values (99);
insert into t values (13);
declare r number;begin for x in (select n,mod(rownum,5)r from t) loop if r is null then r:=x.n;elsif x.r=2then r:=r+x.n;elsif x.r=3then r:=r-x.n;elsif x.r=4then r:=r*x.n;elsif x.r=0then r:=r/x.n;else r:=r**x.n;end if;end loop;DBMS_OUTPUT.PUT_LINE(r);end;
```
Output: 
```
-1055,356943846277162152071601242992595623
```
### 275 Bytes version:
```
declare r number;cursor c is select n,mod(rownum,5) r from t;begin for x in c loop if r is null then r:=x.n;else case x.r when 2 then r:=r+x.n;when 3 then r:=r-x.n;when 4 then r:=r*x.n;when 0 then r:=r/x.n;else r:=r**x.n; end case;end if;end loop;DBMS_OUTPUT.PUT_LINE(r);end;
```
[Answer]
# Java 8, ~~173~~ ~~172~~ ~~167~~ ~~138~~ ~~137~~ ~~118~~ 113 bytes
```
a->{double r=a[0],t;for(int i=1;i<a.length;r=new double[]{Math.pow(r,t),r+t,r-t,r*t,r/t}[i++%5])t=a[i];return r;}
```
**Explanation:**
[Try it here.](https://tio.run/##lVBBbsIwELzzir1USho7JQmURm76A7hwRDm4wYBpcCJnA6pQ3p4uCajqrZZm7bVWMzvjozxLXtXKHLdffVHKpoGl1OY6AdAGld3JQsHq9gTYVu1nqaDwxmaTg/QFTToqQoMSdQErMJBBL/nH9U6wmdxMc4ZiV1mPVEFnkdDvMiyV2eNB2MyoCzxEr0uJh7CuLp5l6DMbILOc6pnqBbuNDoKnee4jiepcWIWtNWBF14sJmahJhEzcvZwrvYUT5fHWaLXZD5bHMOvvBtUprFoMaxphaTwTFt4fJxAxiBkkDGYM5tD5Q9x/cucMIiLHyaAxG0DNK4OFoxJ/o@3TwQeBR/FoKFowSFO6E0e9mLnAUZy@jKz@nq5ZKdAtL48cibSOJ87L0gejm3T9Dw)
```
a->{                     // Method with double-array parameter and double return-type
  double r=a[0],         //  Result-double, starting at the first item of the input
         t;              //  Temp double
  for(int i=1;           //  Index-integer, starting at the second item
      i<a.length;        //  Loop over the input-array
      r=new double[]{    //    After every iteration, change `r` to:
         Math.pow(r,t),  //      If `i%5` is 0: `r^t`
         r+t,            //      Else-if `i%5` is 1: `r+t`
         r-t,            //      Else-if `i%5` is 2: `r-t`
         r*t,            //      Else-if `i%5` is 3: `r*t`
         r/t}[i++%5])    //      Else-if `i%5` is 4: `r/t`
                         //      And increase `i` by 1 afterwards with `i++`
    t=a[i];              //   Change `t` to the next item in the array
  return r;}             //  Return result-double
```
[Answer]
A few tricks can reduce @Willmore´s approach by 23 to 174 bytes (requires php 5.6 or later). The most saving part is removing unneccessary parentheses (-10 bytes).
> 
>  function f($a){while(count($a)>1){$l=array\_shift($a);$r=array\_shift($a);array\_unshift($a,($j=$i++%5)?($j==1?$l-$r:($j==2?$l\*$r:($j==3?$l/$r:$l\*\*$r))):$l+$r);}return end($a);}
> 
> 
> 
But using the `**` operator instead of `pow()` also allows to use `eval` with an array for the operations; and with a few more tricks ...
# PHP >= 5.6, 82 bytes
```
while(--$argc)eval('$x'.['/','**','+','-','*'][$i++?$i%5:2]."=$argv[$i];");echo$x;
```
takes list from command line parameters. Run with `php -nr '<code>'` or [try it online](http://sandbox.onlinephpfunctions.com/code/233f2ac985a4d668abfabc0411a2b48936e6ce63).
## old version, ~~161 157 151 145 144 140 137~~ 117 bytes
```
function f($a){while(count($a)>1)eval('$a[0]=array_shift($a)'.['+','-','*','/','**'][$i++%5].'$a[0];');return$a[0];}
```
The most effective golfing came from writing the intermediate result directly to the first element - after shifting the previous result from the array.
**breakdown**
```
function f($a)
{
    while(count($a)>1)  // while array has more than one element ...
        eval('$a[0]='                           // future first element :=
            . 'array_shift($a)'                 // = old first element (removed)
            . ['+','-','*','/','**'][$i++%5]    // (operation)
            .'$a[0];'                           // new first element (after shift)
        );
    return$a[0];        // return last remaining element
}
```
**test suite**
```
$cases = array (
    0=>[1,2,3,4,5],
    539=>[5,12,23,2,4,4,2,6,7],
    '-1055.356...' => [-8,50,3,3,-123,4,17,99,13],
    256 => [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],
    1 => [1,0,1,0,1,0],
    -16 => [-9,-8,-1],
    -3 => [0, -3],
    -99 => [-99]
);
echo '<table border=1><tr><th>values</th><th>expected</th><th>actual result</th></tr>';
foreach ($cases as $expect=>$a)
{
    $result=f($a);
    echo "<tr><td>[", implode(',',$a),"]</td><td>$expect</td><td>$result</td></tr>";
}
echo '</table>';
```
[Answer]
# [PHP](https://php.net/), ~~135~~ 130 bytes
Thanks @titus, -5 bytes, plus 0 case fix!
```
function f($z){return array_reduce($z,function($c,$x)use(&$i){eval('$c'.['/','**','+','-','*'][$i++?$i%5:5].'=$x;');return$c;});};
```
[Try it online!](https://tio.run/##fZDfT4MwEMef17/islRLxzEHDCdW3JOJDybunTQL6UogmUD4YaYLfzsrynw0d9/L966fXJtWWTU8bStT065QbV4WkFr0m59r3XZ1AUldJ1/7Wh86pc0cr5RFFdIT7xpt3dKcn/VncrQYVWwZszuGbLEwxTZyxobJmOa2vaX5TfAYyCWL6EkwLn4voUr0XPRiILTVTdtABDGZxRAguB6C5xshrH/SmHuEDUgcCecBgxX6JhzXYGt0NxiG6PrTuYf/xkS5uMJJ170hmtWO@9eGIIkUhKRlrROVWTC9NGmMAw5nMtMqK4HFwBDyj@pYHrQ1epMjgTAHCdEzzNF88DTave72L@9vgvRkuAA "PHP – Try It Online")
Less golfy:
```
function f( $t ) {
    return array_reduce( $t,
        function( $c, $x ) use( &$i ) {
            eval('$c'.['/','**','+','-','*'][$i++?$i%5:5].'=$x;');
            return $c;
        }
    );
};
```
Was really rooting for array\_reduce() to work for this, but requires too many chars to beat the current lowest PHP score.
Posting it anyway in case anyone has any suggestions!
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 68 bytes
```
hI,?bL,1:+:-:*:/:^b:L:I{bhv?t.|[O:L:I]h$(P,LbM,OhA,Lh:Ir:A&:M:Pr&.}.
```
That's long… but it uses no evaluation predicate.
### Explanation
* Main predicate
```
hI,                                  Unify I with the first element of the input
   ?bL,                              L is the input minus the first element
       1:+:-:*:/:^b                  Construct the list of predicates [+:-:*:/:^]
                   :L:I{...}.        Call predicate 1 with [[+:-:*:/:^]:L:I] as input
```
* Predicate 1
```
bhv?t.                               If the second element of Input is empty (i.e. L),
                                     unify Output with the last element of Input
|                                    Or
[O:L:I]                              Input = [O:L:I]
       h$(P,                         P is O circularly permutated to the left
            LbM,                     M is L minus the first element
                OhA,                 A is the first element of O
                    Lh:Ir:A&         Call predicate A on [I:First element of L]
                            :M:Pr&.  Call predicate 1 recursively with P:M:
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~29~~ 27 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set")
Anomymous tacit prefix function. Note that `*` is exponentiation in APL.
```
≢{⍎3↓⍕⌽⍵,¨⍨⍺⍴'+-×÷*',¨'⍨'}⊢
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT////1HnoupHvX3Gj9omP@qd@qhn76PerTqHVjzqBaJdj3q3qGvrHp5@eLuWOlBQHSiqXvuoa9H/tEdtE4C6HvVN9fR/1NV8aD1Q/0QgLzjIGUiGeHgG/09TMNQx0jHWMdEx5UpTMNUxNNIxMgaKmAChkY6ZjjlQ9NB6Cx1TA6AiY51D6w2NQIoNzXUsLXUMjYGyQA34IBfIBgMdKAabZqkDMhFoFJBnAKSNIaKWAA "APL (Dyalog Unicode) – Try It Online")
Because APL executes right to left, we can just reverse the order of arguments of the inserted operations and reverse the entire expression. Postfix `⍨` reverses arguments. After doing a perfect shuffle of numbers and operations, we only just need to reverse, flatten, and evaluate:
`≢{`…`}⊢` call the following function with count of and actual numbers as `⍺` and `⍵`:
 `'⍨'` this character
 `'+-×÷*',¨` prepend each of these characters to that; `["+⍨","-⍨","×⍨","÷⍨","*⍨"]`
 `⍺⍴` use the left argument (count of numbers) to cyclically **r**eshape that
 `⌽` reverse
 `⍕` format as flat string
 `3↓` drop leading 3 characters (a space and a symbol and `⍨`)
 `⍎` execute as APL code
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 16 bytes
```
r@[XY]r"p+-*/"gZ
```
[Try it online!](https://ethproductions.github.io/japt/?v=1.4.6&code=ckBbWFldciJwKy0qLyJnWg==&input=Wy04LDUwLDMsMywtMTIzLDQsMTcsOTksMTNd)
Explanation:
```
r@                  #Reduce the input list:
       "p+-*/"      # The list of functions to apply (offset by one due to the behavior of Z)
              gZ    # Choose the one at the current index, wrapping
  [  ]r             # Apply that function to:
   X                #  The result of the previous step
    Y               #  and the current number
                    #Implicitly return the result of the final step
```
[Answer]
# x86-16 + 8087 FPU, 65 bytes
```
00000000: 9bdf 04ad 499b de04 ad49 e334 9bde 24ad  ....I....I.4..$.
00000010: 49e3 2d9b de0c ad49 e326 9bde 34ad 49e3  I.-....I.&..4.I.
00000020: 1fad 919b d9e8 85c9 7413 9c7f 02f7 d99b  ........t.......
00000030: d8c9 e2fb 9d7d 069b d9e8 9bd8 f191 e2c5  .....}..........
00000040: c3                                       .
```
Callable function: input array at `DS:SI`, length in `CX`. Output to `ST` top 8087 register stack.
Listing:
```
9B DF 04    FILD    WORD PTR [SI]   ; load first item to 8087 stack 
AD          LODSW 
49          DEC     CX 
                 
        CALC:
            ; Add 
9B DE 04    FIADD   WORD PTR [SI]   ; add 
AD          LODSW                   ; SI = next input 
49          DEC     CX              ; decrement counter 
E3 34       JCXZ    WOMI_DONE       ; exit if end of input array 
                 
            ; Subtract 
9B DE 24    FISUB   WORD PTR [SI]   ; subtract 
AD          LODSW                   ; SI = next input 
49          DEC     CX 
E3 2D       JCXZ    WOMI_DONE 
                 
            ; Multiply 
9B DE 0C    FIMUL   WORD PTR [SI]   ; multiply 
AD          LODSW                   ; SI = next input 
49          DEC     CX 
E3 26       JCXZ    WOMI_DONE 
                 
            ; Divide 
9B DE 34    FIDIV   WORD PTR [SI]   ; divide 
AD          LODSW                   ; SI = next input
49          DEC     CX 
E3 1F       JCXZ    WOMI_DONE 
                 
            ; Exponent 
AD          LODSW                   ; AX = exponent, SI = next input 
91          XCHG    AX, CX          ; CX = counter for loop (exponent), save CX 
9B D9 E8    FLD1                    ; load 1 into ST 
85 C9       TEST    CX, CX          ; is exponent pos, neg or 0? 
74 13       JZ      EXP_DONE        ; exit (with value 1) if exponent is 0 
9C          PUSHF                   ; save result flags for later 
7F 02       JG      EXP_REP         ; if exp > 1 start calculation 
F7 D9       NEG     CX              ; make exponent positive for loop 
        EXP_REP: 
9B D8 C9    FMUL    ST(0), ST(1)    ; multiply ST0 = ST0 * ST1 
E2 FB       LOOP    EXP_REP 
9D          POPF                    ; restore sign flag from earlier 
7D 06       JGE     EXP_DONE        ; if exponent was neg, divide 1 by result 
9B D9 E8    FLD1                    ; push 1 into numerator 
9B D8 F1    FDIV    ST(0), ST(1)    ; ST0 = 1 / ST1 
        EXP_DONE: 
91          XCHG    AX, CX          ; restore CX 
                 
E2 C5       LOOP    CALC            ; if more input, start again 
             
        WOMI_DONE: 
C3          RET 
```
Sample Output:
[![enter image description here](https://i.stack.imgur.com/argHc.png)](https://i.stack.imgur.com/argHc.png)
[Answer]
# c#, ~~238~~, 202 bytes
```
double d(double[]a){Array.Reverse(a);var s=new Stack<double>(a);int i=0,j;while(s.Count>1){double l=s.Pop(),r=s.Pop();j=i++%5;s.Push(j==0?l+r:j==1?l-r:j==2?l*r:j==3?l/r:Math.Pow(l,r));}return s.Peek();}
```
I didn't see any c# solution so I will give one. This is my first codegolf. I started writing in c# ["two months ago"](https://github.com/spookiecookie/NaturalLanguageDateTime/commit/7a74025562947fb8a784ac2ecdf2f9181782741a "Two months ago Natural Language Date Time parse") (though I know Java to some extent).
It uses **Stack**
[![Try online!](https://i.stack.imgur.com/X1Fva.png)](http://ideone.com/5uYmc0)
**Ungolfed and test cases**
```
using System;
using System.Collections.Generic;
class M 
{
    double d(double[]a) {
        Array.Reverse(a);
        var s = new Stack<double>(a);
        int i=0,j;
        while (s.Count>1)
        {
            double l=s.Pop(),r=s.Pop();
            j=i++%5;
            s.Push(j==0?l+r:j==1?l-r:j==2?l*r:j==3?l/r:Math.Pow(l, r));
        }
        return s.Peek();
    }
    public static void Main()
    {
        int[][] a = new int[][]{
            new int[]{1,2,3,4,5},
            new int[]{5,12,23,2,4,4,2,6,7},
            new int[]{-8,50,3,3,-123,4,17,99,13},
            new int[]{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
            new int[]{1,0,1,0,1,0},
            new int[]{-9,-8,-1},
            new int[]{0,-3},
            new int[]{-99}
        };
        for (int i = 0; i < a.Length; i++)
        {
            Console.WriteLine(new M().d(Array.ConvertAll(a[i], e => Convert.ToDouble(e))));
        }
        Console.ReadKey();
    }
}
```
**Output:**
```
0
539
-1055,35694384628
256
1
-16
-3
-99
```
[Answer]
# PHP, ~~206~~,~~198~~,197 bytes
```
function f($a){while(count($a)>1){$l=array_shift($a);$r=array_shift($a);array_unshift($a,($j=$i++%5)==0?($l+$r):($j==1?($l-$r):($j==2?($l*$r):($j==3?($l/$r):(pow($l,$r))))));}return array_pop($a);}
```
[![Try online!](https://i.stack.imgur.com/X1Fva.png)](http://ideone.com/rKGyUG)
**Ungolfed**
```
<?php
 
function f($a)
{
    while(count($a)>1)
    {
        $l = array_shift($a); $r = array_shift($a);
        array_unshift($a,($j=$i++%5)==0?($l+$r):($j==1?($l-$r):($j==2?($l*$r):($j==3?($l/$r):(pow($l,$r))))));
    }
    return array_pop($a);
}
 
echo f([1,2,3,4,5])."\n";
echo f([5,12,23,2,4,4,2,6,7])."\n";
echo f([-8,50,3,3,-123,4,17,99,13])."\n";
echo f([2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2])."\n";
echo f([1,0,1,0,1,0])."\n";
echo f([-9,-8,-1])."\n";
echo f([0,-3])."\n";
echo f([-99])."\n";
```
In PHP, logic similar to my c# [answer](https://codegolf.stackexchange.com/a/83043/55472) (**202 bytes**) :) .
]