[Question]
  [
**Challenge:**
Take a vector / list of integers as input, and output the largest number that's adjacent to a zero.
**Specifications:**
* As always, optional input and output format
* You may assume that there will be at least one zero, and at least one non-zero element.
**Test cases:**
```
1 4 3 6 0 3 7 0
7
9 4 9 0 9 0 9 15 -2
9
-4 -6 -2 0 -9
-2
-11 0 0 0 0 0 -12 10
0
0 20 
20
```
Good luck and happy golfing!
  
[Answer]
# [MATL](http://github.com/lmendo/MATL), 10 bytes
```
t~5BZ+g)X>
```
[Try it online!](http://matl.tryitonline.net/#code=dH41QlorZylYPg&input=Wy00IC02IC0yIDAgLTld) Or [verify all test cases](http://matl.tryitonline.net/#code=YAp0fjVCWitnKVg-CkRU&input=WzEgNCAzIDYgMCAzIDcgMF0KWzkgNCA5IDAgOSAwIDkgMTUgLTJdClstNCAtNiAtMiAwIC05XQpbLTExIDAgMCAwIDAgMCAtMTIgMTBdClswIDIwXQ).
### Explanation
Let's take input `[-4 -6 -2 0 -9]` as an example.
```
t     % Input array. Duplicate
      %   STACK: [-4 -6 -2 0 -9],  [-4 -6 -2 0 -9]
~     % Logical negate. Replaces zeros by logical 1, and nonzeros by logical 0
      %   STACK: [-4 -6 -2 0 -9],  [0 0 0 1 0]
5B    % Push logical array [1 0 1] (5 in binary)
      %   STACK: [-4 -6 -2 0 -9], [0 0 0 1 0], [1 0 1]
Z+    % Convolution, maintaining size. Gives nonzero (1 or 2) for neighbours of
      % zeros in the original array, and zero for the rest
      %   STACK: [-4 -6 -2 0 -9], [0 0 1 0 1]
g     % Convert to logical
      %   STACK: [-4 -6 -2 0 -9], [0 0 1 0 1]
)     % Use as index into original array
      %   STACK: [-2 -9]
X>    % Maximum of array.
      %   STACK: -2
      % Implicitly display
```
[Answer]
# Haskell, ~~63~~ 43 bytes
```
f x=maximum[a+b|(a,b)<-tail>>=zip$x,a*b==0]
```
Thanks to @MartinEnder for 4 bytes!
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), 9 bytes
```
√º‚ÄöD‚Ç¨P_√èOZ
```
**Explanation**
```
√º‚Äö         # pair up elements
  D        # duplicate
   ‚Ç¨P      # product of each pair (0 if the pair contains a 0)
     _     # logical negate, turns 0 into 1 and everything else to 0
      √è    # keep only the pairs containing at least 1 zero
       O   # sum the pairs
        Z  # take max
```
Doesn't work in the online interpreter, but works offline.
[Answer]
# Pyth, 12 11 10 bytes
```
eSsM/#0,Vt
```
Forms pairs, filters by zero member, sorts by sum, returns largest.
[Answer]
## JavaScript (ES6), ~~59~~ ~~57~~ 56 bytes
```
let f =
    
l=>l.map((n,i)=>m=l[i-1]==0|l[i+1]==0&&n>m?n:m,m=-1/0)|m
console.log(f([1, 4, 3, 6, 0, 3, 7, 0]));       // 7
console.log(f([9, 4, 9, 0, 9, 0, 9, 15, -2]));  // 9
console.log(f([-4, -6, -2, 0, -9]));            // -2
console.log(f([-11, 0, 0, 0, 0, 0, -12, 10]));  // 0
console.log(f([3, 0, 5]));                      // 5
console.log(f([28, 0, 14, 0]));                 // 28
```
*Edit: saved 2 bytes thanks to Huntro*  
*Edit: saved 1 byte thanks to ETHproductions*
[Answer]
## JavaScript (ES6), 53 bytes
```
a=>(m=-1/0,a.reduce((l,r)=>(m=l*r||l+r<m?m:l+r,r)),m)
```
Because I like using `reduce`. Alternative solution, also 53 bytes:
```
a=>Math.max(...a.map((e,i)=>e*a[++i]==0?e+a[i]:-1/0))
```
[Answer]
# Python, 49 bytes
```
lambda a:max(sum(x)for x in zip(a,a[1:])if 0in x)
```
Tests are at **[ideone](http://ideone.com/bYp0HE)**
Zips through the pairs, sums the ones containing any zero, returns the maximum.
[Answer]
## Ruby, 51 bytes
```
->a{a.each_cons(2).map{|a,b|a*b!=0?-1.0/0:a+b}.max}
```
### usage
```
f=->a{a.each_cons(2).map{|a,b|a*b!=0?-1.0/0:a+b}.max}
p f[gets.split.map(&:to_i)]
```
[Answer]
# PHP, ~~77~~ ~~68~~ 71 bytes
~~-3 bytes from anonymous,~~ -4 and -2 from MartinEnder
```
preg_match_all("#(?<=\b0 )\S+|\S+(?= 0)#",$argv[1],$m);echo max($m[0]);
```
run with `php -r '<code>' '<space separated values>'`
[Answer]
# Java 7, ~~118~~ ~~105~~ 106 bytes
```
int d(int[]a){int i=0,m=1<<31,c;for(;++i<a.length;m=a[i]*a[i-1]==0&(c=a[i]+a[i-‚Äå‚Äã1])>m?c:m);return m;}
```
13 bytes saved thanks to *@cliffroot* by using an arithmetic approach instead. 1 additional byte thank to *@mrco* after he discovered a bug (the added test case `2, 1, 0` would return `2` instead of `1`).
**Ungolfed & test code:**
[Try it here.](https://ideone.com/rBqgMX)
```
class M{
  static int c(int[] a){
    int i,
        m = a[i=0],
        c;
    for(; ++i < a.length; m = a[i] * a[i-1] == 0 & (c = a[i] + a[i - 1]) > m)
                           ? c
                           : m);
    return m;
  }
  public static void main(String[] a){
    System.out.println(c(new int[]{ 1, 4, 3, 6, 0, 3, 7, 0 }));
    System.out.println(c(new int[]{ 9, 4, 9, 0, 9, 0, 9, 15, -2 }));
    System.out.println(c(new int[]{ -4, -6, -2, 0, -9 }));
    System.out.println(c(new int[]{ -11, 0, 0, 0, 0, 0, -12, 10 }));
    System.out.println(c(new int[]{ 0, 20 }));
    System.out.println(c(new int[]{ 2, 1, 0 }));
  }
}
```
**Output:**
```
7
9
-2
0
20
1
```
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), 8 bytes
```
·π°2·∫†√ê·∏üS‚Ç¨·πÄ
```
[Try it online!](http://jelly.tryitonline.net/#code=4bmhMuG6oMOQ4bifU-KCrOG5gA&input=&args=LTQsLTYsLTIsMCwtOSwx)
```
·π°2            Overlapping pairs
  ·∫†√ê·∏ü         Remove pairs without zeroes
     S‚Ç¨       Sum of each pair
       ·πÄ      Maximum
```
[Answer]
## [CJam](http://sourceforge.net/projects/cjam/), 16 bytes
```
q~2ew{0&},::+:e>
```
[Try it online!](http://cjam.tryitonline.net/#code=cU4vezpROwoKUX4yZXd7MCZ9LDo6KzplPgoKXW59Lw&input=WzEgNCAzIDYgMCAzIDcgMF0KWzkgNCA5IDAgOSAwIDkgMTUgLTJdClstNCAtNiAtMiAwIC05XQpbLTExIDAgMCAwIDAgMCAtMTIgMTBd) (As a test suite.)
### Explanation
```
q~    e# Read and eval input.
2ew   e# Get all (overlapping) pairs of adjacent values.
{0&}, e# Keep only those that contain a 0.
::+   e# Sum each pair to get the other (usually non-zero) value.
:e>   e# Find the maximum.
```
[Answer]
# MATLAB with Image Processing Toolbox, 32 bytes
```
@(x)max(x(imdilate(~x,[1 0 1])))
```
This is an anonymous function. Example use for the test cases:
```
>> f = @(x)max(x(imdilate(~x,[1 0 1])))
f =
  function_handle with value:
    @(x)max(x(imdilate(~x,[1,0,1])))
>> f([1 4 3 6 0 3 7 0])
ans =
     7
>> f([9 4 9 0 9 0 9 15 -2])
ans =
     9
>> f([-4 -6 -2 0 -9])
ans =
    -2
>> f([-11 0 0 0 0 0 -12 10])
ans =
     0
>> f([0 20])
ans =
    20
```
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 14 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319)
```
‚åà/‚àä2(+‚Üë‚ç®0‚àä,)/‚éï
```
`‚åà/` largest of
`‚àä` the flattened ("**e**nlisted"
`2(`...`)/` pairwise
‚ÄÉ`+` sum (zero plus something is something)
‚ÄÉ`‚Üë‚ç®` taken if
‚ÄÉ`0` zero
‚ÄÉ`‚àä` is a member of
‚ÄÉ`,` the pair (lit. the concatenation of the left-hand number and the right-hand number)
[TryAPL online!](http://tryapl.org/?a=f%u2190%7B%u2308/%u220A2%28+%u2191%u23680%u220A%2C%29/%u2375%7D%20%u22C4%20f%A8%281%204%203%206%200%203%207%200%29%289%204%209%200%209%200%209%2015%20%AF2%29%28%AF4%20%AF6%20%AF2%200%20%AF9%29%28%AF11%200%200%200%200%200%20%AF12%2010%29%280%2020%29&run)
[Answer]
## R, 48 47 bytes
EDIT:
Fixed an error thanks to @Vlo and changed it to read input from stdins, saved one byte by assigning `w` and skipping parantheses.
```
function(v)sort(v[c(w<-which(v==0)-1,w+1)],T)[1]
```
```
v=scan();w=which(v==0);sort(v[c(w-1,w+1)],T)[1]
```
### Unnested explanation
1. Find indices for which the vector `v` takes on the values 0: `w <- which(v == 0)`
2. Create new vector which contains the indices `+-1`: `w-1` and `w+1`
3. Extract elements that match the indices `w-1` and `w+1`
4. Sort in descending order and extract fist element
Note that if the last or first element of `v` is a zero, `w+-1` will effectively fetch an index outside of the length of the vector which implies that `v[length(v)+1]` returns `NA`. This is generally no problem but the `max()` functions inconveniently returns `NA` if there are any occurrences in the vector unless one specifies the option `na.rm=T`. Thus it is 2 bytes shorter to sort and extract first element than to use `max()`, e.g.:
```
max(x,na.rm=T)
sort(x,T)[1]
```
[Answer]
# Mathematica, ~~46~~ 43 bytes
*Saved 3 bytes due to [@MartinEnder](http://ppcg.lol/users/8478).*
```
Max[Tr/@Partition[#,2,1]~Select~MemberQ@0]&
```
Anonymous function. Takes a list of integers as input and returns an integer as output. Based off of the Ruby solution.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~6~~ 5 bytes
```
Sf¬µ∆ù·πÄ
```
[Try it online!](https://tio.run/##y0rNyan8/z847dDWY3Mf7mz4f7hdM/L//2hDHQUTHQVjHQUzHQUDMMMcyIjVUYi2BMtYgoXhpKGpjoKuEUhaFyipawbigeV0LcGChoZgHjLSNQSqMAQbCeQZGcQCAA "Jelly ‚Äì Try It Online")
*-1 remembering it's not a dyadic chain*
```
  ¬µ∆ù     For each pair of adjacent elements, monadically:
S        Sum the pair,
 f       and filter it to only element[s] in the pair.
    ·πÄ    Take the maximum.
```
[Answer]
# [Nekomata](https://github.com/AlephAlpha/Nekomata), 7 bytes
```
q·µóZƒë+a·πÄ
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m70iLzU7PzexJHFZtJJurlLsgqWlJWm6FmsKH26dHnVkonbiw50NS4qTkouhEgtuhkYb6pjoGOuY6RgASXMdg1iuaEugiCWQD8GGpjq6RkBRXRMdXTMgEyioawniGxoCmTCoa2ikYwjSbKBjZBALMR0A)
```
q·µóZƒë+a·πÄ
q           Non-deterministically choose a contiguous subsequence
 ·µóZ         Check that it contains a 0
   ƒë        Unpair; check that its length is 2, and push the two elements
    +       Add
     a      All possible values
      ·πÄ     Maximum
```
[Answer]
# Perl, 42 bytes
Includes +1 for `-p`
Give the numbers on line on STDIN
```
largest0.pl <<< "8 4 0 0 5 1 2 6 9 0 6"
```
`largest0.pl`:
```
#!/usr/bin/perl -p
($_)=sort{$b-$a}/(?<=\b0 )\S+|\S+(?= 0)/g
```
[Answer]
## Julia, ~~56~~ 55 Bytes
```
f(l)=max(map(sum,filter(t->0 in t,zip(l,l[2:end])))...)
```
Create tuples for neighboring values, take those tuples containing 0, sum tuple values and find maximum
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `G`, 36 [bitsv2](https://github.com/Vyxal/Vyncode/blob/main/README.md), 4.5 bytes
```
2l∆õ‚àëw‚Üî
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyJHPSIsIiIsIjJsxpviiJF34oaUIiwiIiwiMSwgMCwgMSwgNywgMTAsIDAiXQ==)
Porting Jelly is (still) always the best option
## Explained
```
z·π†‚ÜîG¬≠‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å§‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå¬≠
z     # ‚Äé‚Å°Overlapping pairs (equivalent to 2l)
 ·π†    # ‚Äé‚Å¢summed (vectorised)
  ‚Üî   # ‚Äé‚Å£with only items in the input kept.
   G  # ‚Äé‚Å§Get the biggest number in that list.
üíé
```
Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
[Answer]
# [Nibbles](http://golfscript.com/nibbles/index.html), 8.5 bytes
```
`/.|!$>>@:?$0+$]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m708LzMpKSe1eMGCpaUlaboWGxL09WoUVezsHKzsVQy0VWIhwlDZndFK0ZY6JjqWOgZQbGiqo2sUqxQLVQAA)
Disgustingly long‚Ä¶
```
`/.|!$>>@:?$0+$]
    !    :       Zip
     $            the input
      >>          with the tail of
        @         the input
   |             Filter by
          ?$0     containing a zero
  .              Map
             +$   sum
`/             ] Maximum
```
[Answer]
# Python 2, 74 Bytes
```
def f(x):x=[9]+x;print max(x[i]for i in range(len(x)) if 0in x[i-1:i+2:2])
```
Cycle through every element, if there's a `0` in the position of either the left or the right of the current element, include it in the generator, and then run it through `max`. We need to pad the list with some non-`0` number. It'll never be included because the slice `[-1:2:2]` won't include anything.
[Answer]
# T-SQL, 182 bytes
**Golfed:**
```
DECLARE @x varchar(max)='1 5 4 3 6 1 3 17 1 -8 0 -7'
DECLARE @a INT, @b INT, @ INT WHILE @x>''SELECT @a=@b,@b=LEFT(@x,z),@x=STUFF(@x,1,z,''),@=IIF(@a=0,IIF(@b<@,@,@b),IIF(@b<>0 or @>@a,@,@a))FROM(SELECT charindex(' ',@x+' ')z)z PRINT @
```
**Ungolfed:**
```
DECLARE @x varchar(max)='1 5 4 3 6 1 3 17 1 -8 0 -7'
DECLARE @a INT, @b INT, @ INT
WHILE @x>''
  SELECT 
   @a=@b,
   @b=LEFT(@x,z),
   @x=STUFF(@x,1,z,''),
   @=IIF(@a=0,IIF(@b<@,@,@b),IIF(@b<>0 or @>@a,@,@a))
  FROM(SELECT charindex(' ',@x+' ')z)z 
PRINT @
```
**[Fiddle](https://data.stackexchange.com/stackoverflow/query/542505/find-the-largest-number-thats-beside-a-zero)**
[Answer]
## PowerShell v3+, 62 bytes
```
param($n)($n[(0..$n.count|?{0-in$n[$_-1],$n[$_+1]})]|sort)[-1]
```
A bit longer than the other answers, but a nifty approach.
Takes input `$n`. Then loops through the indices `0..$n.count`, uses the `Where-Object` (`|?{...}`) to pull out those indices where the previous or next item in the array is `0`, and feeds those back into array slice `$n[...]`. We then `|sort` those elements, and take the biggest `[-1]`.
### Examples
```
PS C:\Tools\Scripts\golfing> @(1,4,3,6,0,3,7,0),@(9,4,9,0,9,0,9,15,-2),@(-4,-6,-2,0,-9),@(-11,0,0,0,0,0,-12,10)|%{""+$_+" --> "+(.\largest-number-beside-a-zero.ps1 $_)}
1 4 3 6 0 3 7 0 --> 7
9 4 9 0 9 0 9 15 -2 --> 9
-4 -6 -2 0 -9 --> -2
-11 0 0 0 0 0 -12 10 --> 0
PS C:\Tools\Scripts\golfing> @(0,20),@(20,0),@(0,7,20),@(7,0,20),@(7,0,6,20),@(20,0,6)|%{""+$_+" --> "+(.\largest-number-beside-a-zero.ps1 $_)}
0 20 --> 20
20 0 --> 20
0 7 20 --> 7
7 0 20 --> 20
7 0 6 20 --> 7
20 0 6 --> 20
```
[Answer]
# q, 38 bytes
```
{max x where 0 in'x,'(next x),'prev x}
```
[Answer]
# J, 18 bytes
```
[:>./2(0&e.\#+/\)]
```
## Explanation
```
[:>./2(0&e.\#+/\)]  Input: array A
                 ]  Identity. Get A
     2              The constant 2
      (         )   Operate on 2 (LHS) and A (RHS)
               \    Get each subarray of size 2 from A and
             +/       Reduce it using addition
           \        Get each subarray of size 2 from A and
       0&e.           Test if 0 is a member of it
            #       Filter for the sums where 0 is contained
[:>./               Reduce using max and return
```
[Answer]
# [Perl 6](https://perl6.org), 53 bytes
```
{max map ->$/ {$1 if !$0|!$2},(1,|@_,1).rotor(3=>-2)}
```
## Expanded:
```
# bare block lambda with implicit signature of (*@_)
{
  max
    map
      -> $/ {           # pointy lambda with parameter ÔΩ¢$/ÔΩ£
                        # ( ÔΩ¢$0ÔΩ£ is the same as ÔΩ¢$/[0]ÔΩ£ )
        $1 if !$0 | !$2 # return the middle value if either of the others is false
      },
      ( 1, |@_, 1 )     # list of inputs, with added non-zero terminals
      .rotor( 3 => -2 ) # grab 3, back-up 2, repeat until less than 3 remain
}
```
[Answer]
# PHP, 66 bytes
```
foreach($a=$argv as$k=>$v)$v||$m=max($m,$a[$k-1],$a[$k+1]);echo$m;
```
Pretty straightforward. Iterates over the input, and when a number is `0`, it sets `$m` to the highest number of the 2 adjacent numbers **and** any previous value of `$m`.
Run like this (`-d` added for aesthetics only):
```
php -d error_reporting=30709 -r 'foreach($a=$argv as$k=>$v)$v||$m=max($m,$a[$k-1],$a[$k+1]);echo$m;' -- -4 -6 -2 0 -9;echo
```
[Answer]
# SPSS Syntax (98 bytes)
Golfed solution:
```
CRE L=lead(A,1).
COMP R=MAX(lag(A),L).
EXE.
SEL IF A=0.
EXE.
AGG
/S=MAX(R).
LIST S
/CAS=1.
```
Ungolfed:
```
CREATE L=lead(A,1).
COMPUTE R=MAX(lag(A),L).
EXECUTE.
SELECT IF A=0.
EXECUTE.
AGGREGATE
/S=MAX(R).
LIST S
/CASES=1.
```
Explanation:
Input values is ordered vertically in a column. 
The first line of code creates a column with the lead number, the number before any given number. MAX(lag,A) returns the lagging number, the number after any given number (in test series A). So the second line of code creates a column with the highest number of neighbourging numbers of any given number. We are only interested in the neighbours of zeros, so the forth line selects all the rows with zeros, which now also include the highest valued neighbours. The 6th and 7th line of code finds the max value of selected neighbours.
With data inputs:
```
* This syntax solves: Returning the greatest adjacent number bigger or equal to itself,
  for any number V.
* CodeGolf asks for the solution for the case V=0.
* Bytes=98.
DATA LIST LIST
/ Sample (A7) a b c d e f g h i j k l m .
BEGIN DATA.
"A" 1, 4, 3, 6, 0, 3, 7, 0
"B" 9, 4, 9, 0, 9, 0, 9, 15, -2
"C" -4, -6, -2, 0, -9
"D" -11, 0, 0, 0, 0, 0, -12, 10
"E"  0, 20
END DATA.
DATASET NAME Inputs WINDOW=FRONT.
FLIP VARIABLES=a b c d e f g h i
/NEWNAMES=Sample.
DATASET NAME CodeGolf WINDOW=FRONT.
DATASET CLOSE Inputs.
CRE L=lead(A,1).
COMP R=MAX(lag(A),L).
EXE.
SEL IF A=0.
EXE.
AGG
/S=MAX(R).
LIST S
/CAS=1.
```
Just change the sample references (A to E) for testing each sample.
]