[Question]
  [
Determining whether a Turing machine halts is well known to be undecidable, but that's not necessarily true for simpler machines.
A *Foo machine* is a machine with a finite tape, where each cell on the tape has an integer or the halt symbol `h`, e.g.
`2 h 1 -1`
The instruction pointer starts by pointing to the first cell:
```
2 h 1 -1
^
```
At every step, the instruction pointer moves forward by the number it points to, then negates that number. So, after one step, it would move forward `2` cells, and turn the `2` into a `-2`:
```
-2 h 1 -1
     ^
```
The Foo machine keeps doing this until the instruction pointer is pointing to the halt symbol (`h`). So, here is the full execution of this program:
```
2 h 1 -1
^
-2 h 1 -1
     ^
-2 h -1 -1
         ^
-2 h -1 1
      ^
-2 h 1 1
   ^
```
The tape is also circular, so if the instruction pointer moves off of one side of the tape, it goes to the other side, e.g.:
```
3 h 1 3
^
-3 h 1 3
       ^
-3 h 1 -3
     ^
-3 h -1 -3
         ^
-3 h -1 3
 ^
3 h -1 3
  ^
```
One interesting thing about these Foo machines is that some do not halt, e.g.:
```
1 2 h 2
^
-1 2 h 2
   ^
-1 -2 h 2
        ^
-1 -2 h -2
    ^
-1 2 h -2
        ^
-1 2 h 2
   ^
```
This program will continue looping in those last four states forever.
So, write a program which determines if a Foo machine halts or not! You can use any (reasonable) input format you like for the Foo machines, and you can choose to use `0` as the halt symbol. You can use any two distinct outputs for the case where it does halt and the case where it doesn't. Your program must, of course, output an answer in a finite amount of time for all valid inputs.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so try to make your program as short as possible!
## Test cases
```
2 h 1 -1
Halts
3 h 1 3
Halts
h
Halts
1 1 1 1 h
Halts
2 1 3 2 1 2 h
Halts
3 2 1 1 4 h
Halts
1 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 h -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36
Halts
2 h
Does not halt
1 2 h 2
Does not halt
8 1 2 3 3 4 8 4 3 2 h
Does not halt
1 2 4 3 h 2 4 5 3
Does not halt
3 1 h 3 1 1
Does not halt
1 2 h 42
Does not halt
```
  
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 71 bytes
```
x=>{for(int i=0,k=0,f=x.Count;i++<1<<f;k%=f)k-=(x[k]*=-1)%f-f;i/=x[k];}
```
[Try it online!](https://tio.run/##fVDLTsMwEDzHX7FEqpRQp82jSBWOixAcAPXGgUPVQ4hsaiXYUuxCqyjfXuwEpXAAr3btHY1nH6WOSi1Ot6URSuaPa6FNLqRZrTg9Heiq5aoJbA6Cxriyzulhdqf20hAxneZJnnNSTSgPq4gGh021vaRREk54xImYUweQ7kTQR9GAYdoABck@N9t2iCmOcYKjpMNoALIeyMY8Hl8JHuyMpI6JXUx7dP7vGWVczXQUWfbfM2sLvLSefYud2Q6L@/vqR2OZawW7mPxix3iRdqgjyO6NFeUucJNXIGQ/ftjC81Eb9m5XKLWq2eylEYathWSBNo2Qb7MnJWTgg4@hCkMCCHmvStWgKrs60@wZQZ5pjshrkefxoApt3iGvLEy5g3ag8aLWjECH/qx1YXk34D8UtdE@XIN/r5gGqQzsLORb0e70BQ "C# (Visual C# Interactive Compiler) – Try It Online")
I don't know if the following is valid, since it requires a custom delegate with a signature of `unsafe delegate System.Action<int> D(int* a);` and has to be wrapped in an `unsafe` block to be used, but here it is anyways:
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 64 bytes
```
x=>f=>{for(int i=0,k=0;i++<1<<f;k%=f)k-=(x[k]*=-1)%f-f;k/=x[k];}
```
[Try it online!](https://tio.run/##fVJNb9wgED2bXzG1lMpO8K4/Uimql62q7qGqUilSDj2s9kBt7EV2QAKSOrL463XBTp320PIxwGN4zPCodFJJxaaqp1rDnZKtog8wokehacOgZj1rqWFw/6wNe9h8rAyXYseF2cMhcsMl0LhEKNCGGl7Bk@Q1fKVcRNooLtrjCahqdbwyjggdoCZoGsi@IfuxkcrTACcp7kha8qurXbbbNWV3QZq4S0g0HLvTJUmy@KJJHLwlHijtVKInqsAwbYCAYD@Op3GxOU5xhpPMYrQAxQwU6zpdZxle6iuSe0/sbT6j2/@Wlcbfma8kN/PxwtVrfON68UL26u2xdB7f/RFY4UPB3mZ/eaf4OrfIlsi9FqPVOfKZd8DFnH48/lbnkxRa9mzzTXHDbrlgLypsvkinSAghhi6OS0Co4QOrZ/0G8rY7pievUPBdyh5k597TqEdWosCoZxS4jaCOhjjqNrdMtObsBA8sCipqqjOMy4GG9pqVYNE/Q3nj/D5A@Jn2RofwHsKDZBqENHB2UOhILXLNem47/ayanrZ62i7f5hc "C# (.NET Core) – Try It Online")
This function takes in an int\* and returns a Action; in other words, it is a curried function. The only reason I use pointers is because of codegolf.meta.stackexchange.com/a/13262/84206, which allows me to save bytes by already having a variable already defined with the length of the array.
Saved 9 bytes thanks to @someone
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~15~~ 11 bytes
```
N1¦ṙ⁸ḢƊÐLḢẸ
```
[Try it online!](https://tio.run/##y0rNyan8/9/P8NCyhztnPmrc8XDHomNdhyf4AOmHu3b8Pzrp4c4Z1o8a5ijo2ik8aphrfbid63D7o6Y1kf//RxvpGOgY6ugaxupEG4OZxkCWARAb6kAgiG0EEtcBkUY6EDmQNiMgywIsZgyEJjoWQGyMpALEMwDTpmBTjUGm6YBIw1gA "Jelly – Try It Online")
A monadic link that takes the input as a list of integers using 0 to mean halt. Returns 0 for halting inputs and 1 for those that don’t halt. 
Avoids the issue of needing to work out number of iterations because of the use of `ÐL` which will loop until no new result seen. 
Thanks to @JonathanAllan for saving a byte!
## Explanation
```
      ƊÐL   | Loop the following as a monad until the result has been seen before:
N1¦         | - Negate the first element
   ṙ⁸       | - Rotate left by each of the elements
     Ḣ      | - Take just the result of rotating by the first element
         Ḣ  | Finally take the first element
          Ẹ | And check if non-zero
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~63~~ 89 bytes
```
def f(x):
 for i in range(2**len(x)):a=x[0];x[0]=-a;b=a%len(x);x=x[b:]+x[:b]
 return a==0
```
[Try it online!](https://tio.run/##NU/LCoMwELznK/ZSULtCHvYSyZeEHCKNrVCiBAvx61PXUBZmZ2eWgdmO/b1GVcozzDA3udUM5jXBAkuE5OMrNLLrPiGeVqu9yZa7kcD0fpyMv1VrzKczaXfPVk@OQQr7N0XwxvByGMusRI4Ce@GQWXVxRVRgHU6HJBUJZRV4/ZbXy1C1y0T5pwNSGu1HTVSUhoSiZnLnGDXK1Og468GWlrg3GaluW8oP "Python 3 – Try It Online")
Also works for Python 2; a byte can be saved in Python 2 by replacing return with print and having the function print to stdout instead of returning. R turns `True` for halting and `False` for non-halting. 
Thanks to @Neil and @Arnauld for noting that I needed to check longer for halting. Thanks to @Jitse for pointing out a problem with `[2,0]`. Thanks to @mypetlion for noting that the absolute of the tape values could exceed the tape length. 
[Answer]
# [Python 3](https://docs.python.org/3/), 91 bytes
```
def f(a):
	s={0,};i=0
	while{(*a,)}-s:s|={(*a,)};a[i]*=-1;i-=a[i];i%=len(a)
	return a[i]==0
```
[Try it online!](https://tio.run/##ZU/dCoMgGL3Op/BmoKHgzwaR@CTRRTAjIdqoxhitZ3eltWGDDznfOec7HO@vsbl10rmrqWGNKpyDZNATI7OymoHk2djWTCitCJ7pkA9vvS2qKmyZasqVpXrFyp50a7olAiS9GR99B1daa@buve1GVKNCEMgI5ARSXmIMvrzceRnRLNq4d4SJFRFuCQxAbHpk@MsKXUREZ/u99HMmMPOv/IUeIoLIdnw5fkGGut61Vl9E9wE "Python 3 – Try It Online")
-40 bytes thanks to JoKing and Jitse
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~46 43~~ 36 bytes
```
{$_.=rotate(.[0]*=-1)xx 2**$_;!.[0]}
```
[Try it online!](https://tio.run/##PUztCoJAEPzdPsUEEir4cXcVQvgS0T8REVJOsIxTSDGf/bq7IIadnZ1Z5tWo/qwfCw4tcujVq@JcDVM9NX5cpGWYRyyYZ/Aw9KrL3lqbbgcFv@@ezRhgpd1YL2hRfG7XRCZpEr8HdR9L2jSHBEPESDghSBLDD5K4dWDZvJFjcMrcLQyOyMyIf2q1dPtkmoTtgGX2BQ "Perl 6 – Try It Online")
Represents halt by `0` and returns true if the machine halts. This repeats the logic `2**(length n)` times, where if the pointer ends up on the halt cell, it stays there, otherwise it will be on a non-halt cell. ~~This works because there are only `2**n` possible states (ignoring halt cells) for the Foo machine to be in, since each non-halt cell has only two states.~~ Okay yes, there are states than that, but due to the limited possible transitions between pointers (and therefore states) there will be less than 2\*\*$\_ states... I think
### Explanation
```
{                                  }  # Anonymous codeblock
                     xx 2**$_         # Repeat 2**len(n) times
            .[0]*=-1                  # Negate the first element
 $_.=rotate(        )                 # Rotate the list by that value
                             ;!.[0]   # Return if the first element is 0
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~14~~ 13 bytes
```
goFć©(š®._}®_
```
[Try it online!](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeXhCf/T892OtB9aqXF04aF1evG1h9bF/9f5Hx1tpGOgY6ijaxirE20MZhoDWQZAbKgDgSC2EUhcB0QagfgK0WCGjhFYyiA2FgA "05AB1E – Try It Online")
Takes the input as a list of integers with 0 as the halting instruction. Returns 1 for halting and 0 for not halting. 
Thanks to @KevinCruijssen for saving 2 bytes!
[Answer]
# Java 8, ~~78~~ ~~79~~ 73 bytes
```
a->{int k=0,l=a.length,i=0;for(;i++<1<<l;k%=l)k-=(a[k]*=-1)%l-l;k/=a[k];}
```
Straight-forward port of [*@EmbodimentOfIgnorance*'s C# .NET answer](https://codegolf.stackexchange.com/a/189575/52210), so make sure to upvote him!  
Thanks to *@Arnauld* for finding two bugs (which also applies to some other answers).
Results in an `java.lang.ArithmeticException: / by zero` error when it's able to halt, or no error if not.
[Try it online.](https://tio.run/##dVJdb4IwFH33VzQmJmWWDsQlZoDJsmxv24t7Mz50CFqpYMrFSAy/nbXFTXSapm167sc59/Zu2J7Zm2XaRIIVBfpgPDv2ECqAAY/QRllpCVzQpMwi4HlGX/OsKLexDHgG88UUJShsmD09qidKQ4eIkFERZytYEx46fpJL7PPhMHCDQPjpIBRWaoeYzdPFQ2i71kDYCn4MNeDXjd9T5LvyWyjyk4Z9zpdoq3ThGUiereYLxCytEaFZVUC8pXkJdKdMIDLc/5IlrKtn1Ld84wNxAXhEHOISRdfBPIN5XcjpPlzSLucykQoh@hxdGlrQJeM/@IY4y5R3W/c7E0V8rdvQkFEXmhhuT60xmajtXSvRZg075n66rNDTBRF9uv95xi1R3TsPgGm@cVEyKaV3W4/Po/IiJasKCnn7X5hZw36nLlm1GRBKKIuieAfKwz9BtzrzmaNYylz@ZqgjBtEavx10rBpJFB@s4/14ZT3Fmdrq5gc)
**Explanation:**
```
a->{                   // Method with integer-array as parameter and no return-type
  int k=0,             //  Index integer, starting at 0
      l=a.length,      //  The length `l` of the input-array
  i=0;for(;i++<1<<l;   //  Loop 2^length amount of times:
          k%=l)        //    After every iteration: take mod `l` of `k`
    k-=                //   Decrease `k` by:
       (a[k]*=-1)      //    Negate the value at index `k` first
                 %l    //    Then take modulo `l` of this
                   -l; //    And then subtract `l` from it
                       //  (NOTE: the modulo `l` and minus `l` are used for wrapping
                       //  and/or converting negative indices to positive ones
  k/=a[k];}            //  After the loop: divide `k` by the `k`'th value,
                       //  which will result in an division by 0 error if are halting
```
[Answer]
# [Haskell](https://www.haskell.org/), 79 bytes
```
s x|m<-length x,let g(n:p)=(drop<>take)(mod n m)(-n:p)=iterate g x!!(2^m)!!0==0
```
[Try it online!](https://tio.run/##bZFNS8QwEIbv@yveLh4SSJd@CWXZ7smLoHjYY60S3Ngt2yQlSd0K/vfadj3YaoZMmGcyw5vMiduzqOu@ko02Dnfc8c1ByKo0um3g@1DaQYk3YS03n3jXBh/C2Eori32GdJNswt6i@5I7vxaqdCd0rBYOJVHbhmbkaHSz2zt@FpRIfYSCpMSfcpUThjuBEp3nkehFUs8LsizonbDOIkOOPGIBC5kfFiv8LIY8nmA8Y8EsCtnV5jQaq9joo0XmSkOW/KlY9h0FRTOWTv3iwRKWDjtm/1WNPJjO24XyeNTJRv/rlcVqJXmlsN3i/gmEXqMMkjePryDPHfw9mtYdnHlQuEGrLtocLXJ70pdhBFgPwxuurBkmQoYZ0YJi@tq@/wY "Haskell – Try It Online")
Returns `True` for halting machines, and `False` otherwise. Input in the form of a list, with `0` representing a halting state.
Assumes a version of GHC greater than 8.4 (released Feb 2018).
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 28 bytes
```
≔⁰ηＦＸ²Ｌθ«§≔θη±§θη≧⁻§θηη»¬§θη
```
[Try it online!](https://tio.run/##ZY47C8IwFIXn5lfc8QYi1MfWqaNgS3EtHUKNSaAkNrk@QPztMdhFEc50@M5jNDKMXk4p1TFa7bAUYHjFzj4Adv6uAm4EHJTTZHDmnMOTFQta096d1APnnBDQKi1J4beZ6YoVjbws/NFqQ9hYd40Cfrhl8sW6YB1h6@mvJqW@h62A/GX90U5ACcOQVrfpDQ "Charcoal – Try It Online") Link is to verbose version of code. Outputs using Charcoal's default Boolean output, which is `-` for true and nothing for false. Explanation:
```
≔⁰η
```
Initialise the instruction pointer.
```
ＦＸ²Ｌθ«
```
Loop as many times as there are theoretically possible states.
```
§≔θη±§θη
```
Negate the value at the instruction pointer.
```
≧⁻§θηη
```
Subtract the new value from the instruction pointer. Charcoal's array accesses are cyclic so this automatically emulates Foo's circular tape.
```
»¬§θη
```
At the end of the loop, output whether the program halted.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~71~~ 67 bytes
```
x=>{for(p=l=x.length,i=2**l;i--;)p+=l-(x[p%l]*=-1)%l;return!x[p%l]}
```
Basically the same as [*@EmbodimentOfIgnorance*'s C# .NET answer](https://codegolf.stackexchange.com/a/189575/52210)
4 byte save thanks to [*@Arnaud*](https://codegolf.stackexchange.com/users/58563/arnauld)
[Try it online!](https://tio.run/##dZDbCsIwDIbvfYp6MXawlW2dII565YXvoF4M7Q4S2rFVGYjPPuvqRLFCCCH/R5I/5@yatcemqhUR8sT7nPUdW99y2Xg1A9bNgYtClbhicRBAWhGS@vWMAfG6Xe3AIWAk8h1IG64ujZia5r0/StFK4HOQheduM1DtyvUnn93c28UYhRhFGJHo4P@odFSpRQwtvWigTdj02EzDyBSxnXrrOpIX8sW4e7GRvEVCKlRqZxZjr@k6WxYsx@10CL1jOWT69ySDGyQc64X9MdTYH9inib/jNJI8z@sf "JavaScript (Node.js) – Try It Online")
# [JavaScript (Node.js)](https://nodejs.org), 61 bytes
```
x=>{for(p=l=x.length,i=2**l;i--;p+=l-(x[p%l]*=-1)%l)x[p%l].f}
```
This version uses `undefined` as a halting symbol and throws a `TypeError: Cannot read property 'f' of undefined` when the machine halts and terminates quietly when the machine doesn't halt.
[Try it online!](https://tio.run/##hZFfa4MwEMCf66fIS2lijaB2UCrZ0x72EQpdH0ST6giJjXE4ip/dZQnrqrMdHJfc3e/@5PKefWRNrqpaYyELOpzJ0JHnC5MK1oSTLuRUnHQZVCT2fZ5WGKf1mnAMu0O95Eef4AgtOXJWyPqBkb3J9xZafRq9OMM9Ss2pqG6VACzjDTV2D/JM5yWkCFx@o1q1Nuj1Xi5FIzkNuTzB1WvGdbNboZGXwUMcgFYUlFWCFgGIAoCjI/pDJVMqmYGuxEwssllOHnGxqx4Ad4kf01fOyGaCjp//Jl4kbYCQGpRmEzOLmHQz1kzD7c9UiRXTc2t18u@oLs2ht02s72l@ocl4XTb3@7F3y9@gm/jOLxj38AU "JavaScript (Node.js) – Try It Online")
[Answer]
# [Scala](http://www.scala-lang.org/), 156 bytes
Still golfable IMO, but I'm okay with it for now. Returns `0` for non-halting `Foo`s and `1` for halting `Foo`s. Takes the input in `a` as an `Array[Int]`, so `h` is taken as `0`.
```
var u=Seq[Array[Int]]()//Keep track of all states
var i=0//Index
while(u.forall(_.deep!=a.deep)){if(a(i)==0)return 1//Check if we are in a previously encountered step ; Halt
u:+=a.clone//Add current state in the tracker
var k=i//Stock temp index
i=(a(i)+i)%a.length//Move index to next step
if(i<0)i+=a.length//Modulus operator in Scala can return a negative value...
a(k)*=(-1)}//Change sign of last seen index
0//Returns 0 if we met a previous step
```
It is pretty long to run (around 4 seconds for all the test cases) because of the multiple full-array lookups I did, plus the `.deep` that create copies... But you can still [try it online.](https://tio.run/##bVDLasMwELzrK9RAQWpUI9stBFMdcuyhpxzTUBR7XasRsqvYfWDy7a6ktPGhYtEuzMwOszqWUsup3b9B2eMnqQyGrx5MdcTrrhsRqqDGNZHF2lr5vX00/Y4Wrotx@pAWD2ID79uZ2xGKPK4ER5@N0kCGpG6t1Jq8JBVAdyVkmJSOytkSRYXg1EI/WINTNBRLJyh1ayD4HIRCSgTdUtFrmWgwr32D3K564FR59S8kyYHeCHKb0hPi0wmhzirTa0MWm6YddIX3gNNiQS94TUJukjHOUub26H8uD1weo3gMTNm5omTmrZjv2VkwR3w2c0geCxl2WBazXQXD3NUdW7mX/9nHPDzNw7yPn5X79Mz38CHoNP0A "Scala – Try It Online")
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 11 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
Ç₧┬òE▐tµ|⌡1
```
[Run and debug it](https://staxlang.xyz/#p=809ec29545de74e67cf531&i=[2,+0,+1,+-1]%0A[3,+0,+1,+3]%0A[0]%0A[1,+1,+1,+1,+0]%0A[2,+1,+3,+2,+1,+2,+0]%0A[3,+2,+1,+1,+4,+0]%0A[1,+2,+0,+2]%0A[8,+1,+2,+3,+3,+4,+8,+4,+3,+2,+0]%0A[1,+2,+4,+3,+0,+2,+4,+5,+3]%0A[3,+1,+0,+3,+1,+1]%0A[1,+2,+0,+42]&a=1&m=2)
It takes input in the form of an integer array, with `0` representing halt.
It outputs `1` for a halting and `0` for a non-halting machine.
[Answer]
# [Perl 5](https://www.perl.org/) `-ap`, 88 bytes
```
for(;$F[$i]&&!$k{"$i|$F[$i]"};$i=($i+$F[$i])%@F){$k{"$i|$F[$i]"}=1;$F[$i]*=-1}$_=!$F[$i]
```
[Try it online!](https://tio.run/##K0gtyjH9/z8tv0jDWsUtWiUzVk1NUSW7WkklswbCV6q1Vsm01VDJ1IbwNVUd3DSr0ZTYGkJ1a9nqGtaqxNsqQrj//xsrGCkYAqGJgsG//IKSzPy84v@6vqZ6BoYG/3ULEgE "Perl 5 – Try It Online")
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 12 bytes
```
!hu.<+_hGtGh
```
[Test suite!](https://pythtemp.herokuapp.com/?code=%21hu.%3C%2B_hGtGh&test_suite=1&test_suite_input=%5B2%2C0%2C1%2C-1%5D%0A%5B3%2C0%2C1%2C3%5D%0A%5B1%2C1%2C1%2C1%2C0%5D%0A%5B2%2C1%2C3%2C2%2C1%2C2%2C0%5D%0A%5B0%5D%0A%5B3%2C2%2C1%2C1%2C4%2C0%5D%0A%5B1%2C2%2C0%2C2%5D%0A%5B1%2C2%2C4%2C3%2C0%2C2%2C4%2C5%2C3%5D%0A%5B3%2C1%2C0%2C3%2C1%2C1%5D%0A%5B2%2C0%5D&debug=0)
Uses the straight-forward approach. Recurse until we see the list twice in an identical state. For programs that halt, the list will eventually have a leading `0` because that's where the recursion stops. For programs that don't halt, the list won't begin with the `0`, but rather be in a state from
which the process would be periodic and therefore the Foo machine wouldn't halt.
[Answer]
# [Attache](https://github.com/ConorOBrien-Foxx/Attache), 40 bytes
```
Not@&N@Periodic[{On[0,`-,_]&Rotate!_@0}]
```
[Try it online!](https://tio.run/##XZBBa8MwDIXv@RUZjJ5kiKW0ywajgd2zMnYzpgupu@XSlMa3sd@ePSUkYbORbT1/PFuqY6ybrzCc06fnoepiuanKQ7i13alt3PfrxWX0YejoN29drGO4O5bZjx@qEE69u79em0@fJIdbe4nvoY8vdR96d6bUJSmGY8rIkrGeplzGXOY0mw@WprkIrBjpyqs4CZbyRdrvndqTYTJCJiezJbMj80CmIPOIqwyhCAALwgKxYCwgC8oW@JFhDXUBxaAYFINiUAyKYcZwE3ACTvQ5cAJOwMnOj99Zil7r0g7wnBZjPYKZU4EQ@seqlI37du2SaGNIV/vXN2efeD/8Ag "Attache – Try It Online")
## Explanation
```
{On[0,`-,_]&Rotate!_@0}
```
This performs a single iteration of the Foo machine; it negates the first member, then rotates the array by the (original, non-negated) first element of the array.
`Periodic` will apply this function until a duplicate result is accumulated. A machine either halts, or goes into a trivial infinite loop. If it halts, the first element will be 0. Otherwise, it will be non-zero.
`&N` is a golfy way of obtaining the first element of a numeric array. Then, `Not` returns `true` for 0 (halting machines) and `false` for anything else (non halting machines).
]