[Question]
  [
For this challenge, a linked list looks like this:
```
[1, 2, 4, 0, 6, 1, 3, 1]
```
You'll notice there's no data; each item in the list is just a reference to the index of the next one. Your task is to write a program or function which will follow a linked list like this forever, outputting each item as it is encountered. For example, for the above input:
```
[1, 2, 4, 6, 3, 0, 1, ...]
```
Input and output can be represented in any reasonable manner. All numbers in the input will be valid indices in the list, and you can choose if it's 0- or 1-indexed. The output will be infinite, and as long as your program would *theoretically* give a correct result given infinite time and resources it's valid.
**Test cases:**
Zero indexed, using lists.
```
[0]         -> [0, 0, ...]
[1, 0]      -> [1, 0, 1, ...]
[0, 1, 2]   -> [0, 0, ...]
[2, 1, 0]   -> [2, 0, 2, ...]
[4]         -> (does not need to be handled)
```
  
[Answer]
# [Haskell](https://www.haskell.org/), 17 bytes
```
f x=iterate(x!!)0
```
0-indexed
[Try it online!](https://tio.run/##y0gszk7Nyfn/P02hwjazJLUosSRVo0JRUdPgf25iZp5tQVFmXomKQppCtJGOoY5B7H8A "Haskell – Try It Online")
[Answer]
# [convey](http://xn--wxa.land/convey/), 36 29 bytes
```
v<<<<,{
\~./."
>"`=>!
 >!0<"}
```
[Try it online!](https://xn--wxa.land/convey/run.html#eyJjIjoidjw8PDwse1xuXFx+Li8uXCJcbj5cImA9PiFcbiA+ITA8XCJ9IiwidiI6MSwiaSI6IjEgMiA0IDAgNiAxIDMgMSJ9)
[![top](https://i.stack.imgur.com/v96lM.gif)](https://i.stack.imgur.com/v96lM.gif)
`{` gets the input, that will get looped around in the upper two rows, while outputting downwards the length `\`, its indices `/.` and a copy of itself `"`. It will only continue after `~.` (batch) if `n` elements reach `~.`, whereas `n` will be the length.
[![run for 2 1 0](https://i.stack.imgur.com/LCl1y.gif)](https://i.stack.imgur.com/LCl1y.gif)
We then take `!` `n` copies of the current index `i` (starting with 0) and compare `=` them to the indices of the list. This returns either 1 or 0. We take the correspondent element of the copied list so many times, effectively filtering the others out. The next index then gets copied to the output `"}` and waits for the next iteration.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 4 bytes
```
¡!¹←
```
[Try it online!](https://tio.run/##yygtzv7//9BCxUM7H7VN@P//f7SxjpGOYSwA "Husk – Try It Online")
1-indexed, returns an infinite list.
## Explanation
```
¡!¹←
   ← take the first element as the start
¡    apply the following infinitely:
 !¹  index into the input
```
[Answer]
# [JavaScript (V8)](https://v8.dev/), 29 bytes
Zero-indexed. Prints forever. (Where *forever* means *until the call stack overflow*.)
```
f=a=>print(a.i=a[~~a.i])|f(a)
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNEts/j/P8020dauoCgzr0QjUS/TNjG6rg5Ix2rWpGkkav5P04g21FEw0lEw0VEw0FEw01EAco2BZKzmfwA "JavaScript (V8) – Try It Online")
### Commented
```
f = a =>       // f is a recursive function taking the input array a[]
  print(       // print:
    a.i =      //   update the current index, which is stored in the
               //   property 'i' of the surrounding object of a[]:
      a[~~a.i] //     it's initially undefined, so we use '~~' to coerce
               //     it to a number (zero) on the first iteration
  )            // end of print()
  | f(a)       // unconditional recursive call
```
The `a.i` trick saves 2 bytes over the more straightforward version:
```
f=(a,i=0)=>print(i=a[i])|f(a,i)
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNEts/j/P81WI1En09ZA09auoCgzr0Qj0zYxOjNWsyYNJK75P00j2lBHwUhHwURHwUBHwUxHAcg1BpKxmv8B "JavaScript (V8) – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~35~~ 32 bytes
-3 bytes thanks to Giuseppe.
```
function(l)repeat show(T<-l[+T])
```
[Try it online!](https://tio.run/##K/qfpmCr8D@tNC@5JDM/TyNHsyi1IDWxRKE4I79cI8RGNydaOyRW879ymkayhqGOAghpanKBuUZIbKA4kGsM4xqDuSBZqEKggClYtzlYxgRIamr@BwA "R – Try It Online")
1-indexed, prints the list indefinitely. A rare use for `show`, which is 1 byte shorter than `print`, and separates the output unlike `cat`.
The variable `T` is initially  `TRUE`; `+T` converts it to the integer `1`, and thereafter it is updated at each step to the relevant list entry.
[Answer]
# [Rattle](https://github.com/DRH001/Rattle), 11 bytes
```
|IP0[gpP~]0
```
[Try it Online!](https://www.drh001.com/rattle/?flags=&code=%7CIP0%5BgpP%7E%5D0&inputs=%5B2%2C1%2C0%5D)
Update: changing link to new Rattle interpreter (please let me know if there are issues - I couldn't find any issues but this is a newer version of Rattle)
# Explanation
```
|                  takes the user's input
  I                stores the user's input in an array
    P0             sets the pointer to 0
       [ ...... ]0 infinite loop
         g         gets the value at the pointer
           p       prints this value
             P~    sets the pointer to this value
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 4 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
0[è=
```
0-based indexing.  
Prints the numbers newline-delimited to STDOUT indefinitely.
[Try it online](https://tio.run/##yy9OTMpM/f/fIPrwCtv//6MNdRSMdBRMdBQMdBTMdBSAXGMgGQsA) or [verify all test cases, but only printing the first 10 numbers of each](https://tio.run/##yy9OTMpM/V@m5JlXUFpipaBkX6nDpeRfWgLh6VSG6Ln8N4g@vML2v59loHLtoW32/6OjDWJ1og11QKSBjqGOEZA20oHwgTwdEx0DHTMg31jHEChiEhsLAA).
**Explanation:**
```
0     # Start with index 0
 [    # Loop indefinitely:
  è   #  Use the current integer to index into the (implicit) input-list
   =  #  Print it with trailing newline (without popping, so it'll become the index for
      #  the next iteration)
```
[Answer]
# [dc](https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html), ~~29~~ 28 bytes
```
[z1-:az0<L]dsLx0[;aplLx]dsLx
```
[Try it online!](https://tio.run/##S0n@b6hgpGCiYKBgpmCoYKxg@D@6ylDXKrHKwMYnNqXYp8Ig2jqxIMenAsz5/x8A "dc – Try It Online")
0-indexed; takes input on the stack (just prepend it). If we assume input is already in `a`, cut off the first 16 bytes. Will perish when the call stack overflows.
```
[ # Phase 1: shove stuff into an array
  z1-  # if there are 7 things on the stack, push 6
  :a   # store whatever was on top into e.g. a[6]
  z0<L # loop while stack isn't empty
]dsLx  # execute immediately and with extreme prejudice
0 # first index to check out
[ # Phase 2: the challenge
  ;a  # push a[tos]
  p   # print it
  lLx # loop forever
]dsLx # autobots, roll out
```
~~I feel like the `0!=` should be reducible to `1>`~~ never mind, I just can't read. Woohoo!
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~12~~ 11 bytes
```
{⍺∇⎕←⍵⌷⍺}∘0
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/6sf9e561NEOFAByH/VufdSzHShS@6hjhsH/NLBQ36Ou5ke9ax71bjm03vhR20Sg0uAgZyAZ4uEZ/D9NAcjyCvb3U4821FEw0lEw0VEw0FEw01EAco2BZKw6AA "APL (Dyalog Unicode) – Try It Online")
0-indexed, takes input as the left argument.
-1 byte from user.
```
{⍺∇⎕←⍵⌷⍺}∘0
{⍺∇⎕←⍵⌷⍺}∘0 take 0 as initial right argument
   ⎕←⍺⌷⍵    print element at right arg
 ⍺∇ ⍵⌷⍺     recursive call with the input and new right arg
```
[Answer]
# [Whitespace](https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.php), 89 bytes
```
[S S S T    N
_Push_1][S N
S _Duplicate_1][S N
S _Duplicate_1][S N
S _Duplicate_1][N
S S N
_Create_Label_READ_INPUT_LOOP][T    N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve][N
T   S S N
_If_0_Jump_to_Label_DONE_READING][S S S T   N
_Push_1][T  S S S _Add][S N
S _Duplicate][S N
S _Duplicate][N
S N
N
_Jump_to_Label_READ_INPUT_LOOP][N
S S S N
_Create_Label_DONE_READING][S N
N
_Discard_top][N
S S T   N
_Create_Label_PRINT_LOOP][T T   T   _Retrieve_at_address][S N
S _Duplicate][T N
S T _Print_as_integer][S S S T  S S T   N
_Push_9_tab][T  N
S S _Print_as_character][N
S N
T   N
_Jump_to_Label_PRINT_LOOP]
```
Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.  
`[..._some_action]` added as explanation only.
1-based indexing.  
Whitespace doesn't have any lists, so we'll read the numbers one at a time from STDIN. Input numbers will end with a trailing `0`, so the program knows when all the numbers are read from STDIN. I.e. test case `[1,2,4,0,6,1,3,1]` would be taken as input `2\n3\n5\n1\n7\n2\n4\n2\n0`.  
Outputs the numbers tab-delimited to STDOUT indefinitely.
[**Try it online**](https://tio.run/##PYzLCYBADETP86pICboq1iOyoDdBwfLjJguG/GbyyHucT72vba/uZiYM6xlNKAKlZ7n8ZyBFziSbaA@CUTodFO6FiYWRlcLcavgA) (with raw spaces, tabs and new-lines only).
**Explanation in pseudo-code:**
```
Integer index = 1
Start READ_INPUT_LOOP:
  Read input as integer from STDIN, and store it in the heap at address `index`
  Integer input = retrieve the input from address `index`
  If(input == 0):
    Jump to DONE_READING
  index = index + 1
  Go to next iteration of READ_INPUT_LOOP
Label DONE_READING:
  Reset index to 1
  Start PRINT_LOOP:
    index = retrieve integer from heap at address `index`
    Print `index` as integer to STDOUT
    Print character '\t'
    Go to next iteration of PRINT_LOOP
```
[Answer]
# [Rust](https://www.rust-lang.org/), ~~50~~ 49 bytes
```
|a|(|mut i|loop{i=a[i];println!("{}",i)})(0usize)
```
[Try it online!](https://tio.run/##HYzLCoMwEEX3fsXV1QykYB90UR@f0U3pIkgCAxpFYxc1@fY0dHPhcDh33TefrMOkxRHjKIDReNgHrKOnGdp9k6/pGace2Xcp6EBh2j0kjPO8HNLpl7ybZRXnR1dSdcRKCUem@p9yavKnpY8ZSjorXBRuCrXCXSHjNS9zEdMP "Rust – Try It Online")
[Answer]
# [CJam](https://sourceforge.net/p/cjam), ~~14~~ 12 bytes
```
q~{_T=:Tp1}g
```
Input is taken from STDIN, 0-based, with format `[1 2 4 0 6 1 3 1]`.
Output is printed to STDOUT, separated by newlines.
[**Try it online!**](https://tio.run/##S85KzP3/v7CuOj7E1iqkwLA2/f//aEMFIwUTBQMFMwVDBWMFw1gA) Or verify test cases: [**1**](https://tio.run/##S85KzP3/v7CuOj7E1iqkwLA2/f//aINYAA), [**2**](https://tio.run/##S85KzP3/v7CuOj7E1iqkwLA2/f//aEMFg1gA), [**3**](https://tio.run/##S85KzP3/v7CuOj7E1iqkwLA2/f//aAMFQwWjWAA), [**4**](https://tio.run/##S85KzP3/v7CuOj7E1iqkwLA2/f//aCMFQwWDWAA).
## How it works
```
q               e# Read input as a string
 ~              e# Evaluate: gives the input as a list of numbers
  {       }g    e# Do...while, popping condition from the stack
         1      e# Push 1 at the end of each iteration, to produce an infinite loop
   _            e# Duplicate the input list
    T           e# Push variable T. This is initially 0
     =          e# Get entry at that index (0-based)
      :T        e# Assign the result to variable T
        p       e# Print with newline
```
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), ~~37~~ 34 bytes
```
def f(l,i=0):print(l[i]);f(l,l[i])
```
[Try it online!](https://tio.run/##K6gsycjPM7YoKPr/PyU1TSFNI0cn09ZA06qgKDOvRCMnOjNW0xokCGb9h4imaUQb6igY6SiY6CgY6CiY6SgAucZAMlZT8z8A "Python 3.8 (pre-release) – Try It Online")
thanks [user](https://codegolf.stackexchange.com/users/95792/user) for helping save 3 bytes
slightly modified version of 31 bytes, but it prints an extra zero at the beginning
```
def f(l,i=0):print(i);f(l,l[i])
```
[Try it online!](https://tio.run/##K6gsycjPM7YoKPr/PyU1TSFNI0cn09ZA06qgKDOvRCNT0xokkhOdGav5HyKUphFtqKNgpKNgoqNgoKNgpqMA5BoDyVhNzf8A "Python 3.8 (pre-release) – Try It Online")
[Answer]
# [Julia 1.0](http://julialang.org/), ~~24~~ 21 bytes
```
>(a,i=1)=a>@show a[i]
```
[Try it online!](https://tio.run/##HYxBCoAgFET3/xQDbZQ@oRbtlO4hLtxlCC0s6vZmbmbeY2COO6eo31qdiJyslja6rezng@hTqDmVCxbkNcMwFoZirIymc8tAg1d/NO@t@mR@NB1VABE50Y@mEVrWDw "Julia 1.0 – Try It Online")
1-indexed
[Answer]
# [PHP](https://php.net/), 34 bytes
```
for($i=1;;)echo($i=$argv[$i])."
";
```
1-indexed, because `$argv` contains the script name at index 0, first argument is then `$argv[1]`. Too bad the new line takes a lots of bytes more, without it the brackets around `$i=$argv[$i]` are not necessary..
[Try it online!](https://tio.run/##K8go@G9jXwAk0/KLNFQybQ2trTVTkzPyQWyVxKL0smiVzFhNPSUuJev///8b/Tf@b/rf8L85kGXy3wgA "PHP – Try It Online")
[Answer]
# [Java (JDK)](http://jdk.java.net/), 46 bytes
```
a->{for(int i=0;;)System.out.println(i=a[i]);}
```
[Try it online!](https://tio.run/##ZY49z4JAEIR7f8WUkJwXv2KD2Ly1lSWhWE8wywt3hNvTGMJvx9PY2cxmnkx2pqE7LZvr/9yHS8sGpiXvcSK2GBfAl3ohiaeJYR2EW10Ha4Sd1X/O@tBVw4GtFOURNfKZlsexdkMSEThfZVl6fnqpOu2C6H6IuLUJ51RwmWbTnP303B1f0cUNyVli/FaUoOHm088koNZkTNVLYqsHPr3jWmGjsFNYKewVot1GndL372kxzS8 "Java (JDK) – Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 38 bytes
```
i;f(int*a){printf("%d ",i=a[i]);f(a);}
```
[Try it online!](https://tio.run/##XYrNCsIwEITvPsVSEHbLFvzDS8iTlB5CbEqgaYMNiIa8unFBvDiHYYbvs91kba1eOfRLag3leJfhsNnfoGGvTe8HEmpIlRqMX5Ag70AiGqR@AA35yHBiuDAcGK4Mcs/SRf28Nupg5nm1uPnXuDpMRF8YxmDjEyMn/kcOo6xS39bNZtpq9/gA "C (gcc) – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 31 bytes
Note that tests don't work, but `print` returns its input so we can recurse. Curiously this is different from `cat` and `show` which return NULL.
```
function(l,i=1)f(l,print(l[i]))
```
[Try it online!](https://tio.run/##Fcy9CoAgFIbhvav4oEXBxXbvoi0awh8SxRN6pO7eanqn560jwGCEXixHKiKraLQMX68aC4u8xV3KMWP1jRscoRDjpprgugcTGh82wT/n0du/mIKwQqvlUy8 "R – Try It Online")
[Answer]
# [Bash](https://www.gnu.org/software/bash/), 51 50 bytes
```
f(){
A=($@)
I=0
while
I=${A[$I]}
do
echo $I
done
}
```
[Try it online!](https://tio.run/##PcuxDoIwEAbg/X@KM3agg6EgcSOBsc9gHECKbSIlEYwD8Oz1rMZb7sv/37XNZMN@l7bOpy0boU/kgrpMRCWhS4WXdXfDEkt9FvqyoRthrnYkoZneYAuPp08kLSCeWM1mmp2/kahi1jNotabp6JCrtR9mbAD4jTLKqSBFJ9aRspipX/Pd6nMTlf@zAuEN "Bash  Try It Online")
I was disappointed to find I could not use $@ as an array. I had to copy it to A.
The test code limits the output to 20 lines, and wraps it (or tries). Terminates only on signal, like SIGPIPE.
Edit: TIO seems to say I don't need the final newline. -1. Note that all my other newlines could become either spaces or semicolons, but I felt newlines had a better (weirder?) style in this case.
[Answer]
# [MATLAB](https://www.mathworks.com/products/matlab.html) and [Octave](https://octave.org), 20 bytes 32 bytes
(I've been informed that it is not allowed on this site to assume the input is an array, original answer below the line.)
```
@(x)eval('1,while 1,x(ans),end')
```
Thanks to [Luis Mendo](https://codegolf.stackexchange.com/users/36398/luis-mendo) for this solution to make a function out of my original answer. It is two bytes shorter than the more obvious solution:
```
function f(x),1,while 1,x(ans),end
```
[Try it online!](https://tio.run/##y08uSSxL/f/fQaNCM7UsMUdD3VCnPCMzJ1XBUKdCIzGvWFMnNS9FXfM/kKkRbaSjYKyjYKoDlFQwB7NNdBSMYjX/AwA "Octave – Try It Online")
---
```
1,while 1,x(ans),end
```
1-indexed, the input is in matrix `x`. For example:
```
>> x = [1, 2, 4, 0, 6, 1, 3, 1] + 1;
>> 1,while 1,x(ans),end
ans =
     1
ans =
     2
ans =
     3
ans =
     5
ans =
     7
ans =
     4
ans =
     1
...
```
`ans` is the default variable expression results get assigned to. The code above is equivalent to:
```
ans = 1
while 1
   ans = x(ans)
end
```
The result of the assignment is shown to the command line because statements are not terminated with a semicolon.
[Answer]
# Common Lisp, 44 bytes
### (Function prints in the square bracket + comma style of most languages)
I used Common Lisp's `format` specifiers to handle all the control flow.
```
(defun f(l)(format t"[~{~a~:*~v@*~^, ~}]"l))
```
### Example usage:
```
(defparameter *test* '(1 2 4 0 6 1 3 1))
(f *test*) ; Will print [1, 2, 4, 6, 3, 0, 1, ... and so forth forever.
```
Edit: Technically the ending square bracket would never be reached, so we may omit the closing square bracket in the format string to have a 43 byte solution.
[Answer]
# [Python 3](https://docs.python.org/3/), ~~49~~ 37 bytes
Thanks to Jo King for -12 bytes!
```
def f(l,c=0):
 while 1:c=l[c];yield c
```
[Try it online!](https://tio.run/##DcpBCsMgFEXReVbxhlr@QJPSQYorESnBaCPITxChZvXWyYUD97rrcfLS@x4iosjkjZLrhN@RcoBevcnWu/edQt7he4MZl9WEmfAkKMKLMLiMOjldJXEVD8uhVdEk4lnwQWKUjb9BaCWd7H8 "Python 3 – Try It Online")
# Original
```
def f(l):
    c=l[0]
    while 1:c = l[c];yield c
```
[Try it online!](https://tio.run/##K6gsycjPM/7/PyU1TSFNI0fTiksBCJJtc6INYsHM8ozMnFQFQ6tkBVuFnOjkWOvKzNScFIXk//8B "Python 3 – Try It Online")
This code takes an input, sets c(which holds the index), then continuosly `yield`s c after updating it to the new location. While this isn't the best answer on here, even for python,  ~~I don't think it can really be improved upon without using recursion.~~  Clearly, I was wrong.
[Answer]
## Batch, 94 bytes
```
@set n=0
:g
@call:c %*
@echo %n%
@goto g
:c
@for /l %%i in (1,1,%n%)do @shift
@set n=%1
```
Takes a 0-indexed list of command line arguments (change `=0` to `=1` and `%1` to `%0` for 1-indexing). The `:c` subroutine exists to shift a copy of the command line, thus avoiding destroying the command line. For short lists (up to 9 elements), the following 51-byte 1-indexed script suffices:
```
@set n=1
:g
@call set n=%%%n%
@echo %n%
@goto g
```
[Answer]
# [Perl 5](https://www.perl.org/) `-a`, 22 bytes
```
$_=$F[$_]while say$_*1
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lbFLVolPrY8IzMnVaE4sVIlXsvw/39DBYN/@QUlmfl5xf91fU31DAwN/usmAgA "Perl 5 – Try It Online")
Input needs to be space separated.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 15 bytes
```
≔⁰ηＷ¹«≔§θηηＩηＤ⎚
```
[Try it online!](https://tio.run/##S85ILErOT8z5/9@xuDgzPU/DQEchQ9OaqzwjMydVQcNQU6GaixMq5VjimZeSWqFRCFICUcYZUJSZV6LhnFhcopGhCRJwKc0t0AAxnHNSE4tArNr//6OjDXUUjHQUTHQUgOab6SgAucZAMjb2v25ZDgA "Charcoal – Try It Online") Link is to verbose version of code. 0-indexed. Charcoal rate-limits its output, so TIO will probably time out rather than fill its output buffer. Explanation:
```
≔⁰η
```
Start at index 0.
```
Ｗ¹«
```
Repeat forever.
```
≔§θηη
```
Update the index.
```
ＩηＤ⎚
```
Output the index, clearing the canvas for the next loop.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 39 bytes
```
(,)*(((?<-1>,)|\d+)+.*)
$3$*,$2,
}*`\G,
```
[Try it online!](https://tio.run/##K0otycxL/P9fQ0dTS0NDw95G19BOR7MmJkVbU1tPS5NLxVhFS0fFSIerVishxl3n/39DHSMdEx0DHTMdQx1jHUMA "Retina 0.8.2 – Try It Online") 0-indexed. Explanation: The current index is encoded in unary as the number of leading `,`s.
```
(,)*(((?<-1>,)|\d+)+.*)
```
Match the current index, then as many commas and integers as possible, but only matching as many commas as the current index. The last submatch is therefore the next index.
```
$3$*,$2,
```
Replace the current index with the submatch in unary, then append the original input and an extra comma to ensure that the buffer changes each time (since Retina 0.8.2 doesn't have truly infinite loops).
```
}`
```
Repeat until the buffer stops changing, which it won't because we append a comma to the end on each loop.
```
*`\G,
```
Convert the current index to decimal and print it.
[Answer]
# [k4](https://code.kx.com/q/ref/), ~~17~~ 13 bytes
```
{0W(0N!x@)/0}
```
Loops "infinitely" via `0W`, outputting (`0N!`) the index in question. Begins with the first value in the input, i.e. `x 0`.
[Answer]
# [JQ](https://stedolan.github.io/jq/), 37 bytes
```
[0,.]|recurse([.[1][.[0]],.[1]])|.[0]
```
[Try it online!](https://tio.run/##yyr8/z/aQEcvtqYoNbm0qDhVI1ov2jAWSBjExuqAmLGaNSAOUJmRjqGOQSwA)
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~27~~ 23 bytes
*Saved a whooping 4 bytes, thanks to [Dingus](https://codegolf.stackexchange.com/users/92901/dingus)!!*
```
f=->a,i=0{f[a,p(a[i])]}
```
[Try it online!](https://tio.run/##KypNqvz/P81W1y5RJ9PWoDotOlGnQCMxOjNWM7b2f1p0tKGOgpGOgomOgoGOgpmOApBrDCRjY/8DAA "Ruby – Try It Online")
---
# [Ruby](https://www.ruby-lang.org/), 23 bytes
*As suggested by [Dingus](https://codegolf.stackexchange.com/users/92901/dingus), here is another way, and it prevents the "stack overflow" error!!*
```
->a,i=0{loop{p i=a[i]}}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y5RJ9PWoDonP7@gukAh0zYxOjO2tvZ/WnS0oY6CkY6CiY6CgY6CmY4CkGsMJGNj/wMA "Ruby – Try It Online")
[Answer]
# FALSE, 65 24 21 bytes
```
[c;[1_][ø$.32,c;\-]#]
```
[Try it online!](https://tio.run/##S0vMKU79/z862TraMD42@vAOFT1jI51k6xjdWOXY//8B)
Assumes that array is already pushed onto stack and len(array)-1 is stored in c.
-41 because Razetime pointed out that I could just submit a function instead.
-3 because of removed redundancy.
## Explanation
```
[c; {Push len(array) on stack for index 0}
[1_] {Value for true}
[ø {Get value at current index}
$. {Dup and print int}
32, {Print space}
c;\- {Subtract c by this new value to get new index}
]#] {Do lambda 2 while lambda 1 outputs true (forever)}
```
]