# Help with  Null

**URL:** <https://community.wolfram.com/t/help-with-null/6925>\
**Category:** Questions\
**Created:** [October 13, 2015, 4:47am UTC](https://community.wolfram.com/t/help-with-null/6925 "2015-10-13T04:47:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![22padrinos](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/22padrinos/32/29645_2.png) [@22padrinos](https://community.wolfram.com/u/22padrinos)\
**Post date:** [October 13, 2015, 4:47am UTC](https://community.wolfram.com/t/help-with-null/6925/1 "2015-10-13T04:47:16Z")

</div>

I would like to ask for your help with the next question i have, my function diamond works as i hope,see you  
Here is malla

```
malla={{100, 0, 0, 0, 0, 0, 100}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 
  0}, {0, 0, 0, 102, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 
  0, 0}, {100, 0, 0, 0, 0, 0, 100}};

```

Next the function diamond

```
diamond[main_, gx_, gy_, grider_] := 
 Module[{grid = grider, last, half, b, c, g, h, d, a, e, f, i, top, 
   left, botton, right},
  last = Length[grid] - 1;
  half = Ceiling[last/2.];
  b = {gx, gy};
  c = {gx + last, gy};
  g = {gx, gy + last};
  h = {gx + last, gy + last};
  d = {gx + half, gy + half}; (* midpoint*)
  (* extreme corners*)
  If[gy - half >= 0 , a = {gx + half, gy - half}, a = Null];
  If[gx - half >= 0, e = {gx - half, gy + half}, e = Null];
  If[gx + last + half < Length[main], 
   f = {gx + last + half, gy + half}, f = Null];
  If[gy + last + half < Length[main], 
   i = {gx + half, gy + last + half}, i = Null];
  {a, b, c, d, e, f, g, h, i}]

```

Test of diamond function

```
diamond[malla, 1, 1, malla]

```

the results that throws the diamond function are the ones I hope, the problem arises when I try to use the following function called average,

```
average[a_, b_, c_, d_, main_] := Module[{total = 0, count = 0, x},
  If[a != Null, x = main[[a[[1]], a[[2]]]]; 
   If[x != 0, total = total + x ; count++]];
  If[b != Null, x = main[[b[[1]], b[[2]]]]; 
   If[x != 0, total = total + x ; count++]];
  If[c != Null, x = main[[c[[1]], c[[2]]]]; 
   If[x != 0, total = total + x ; count++]];
  If[d != Null, x = main[[d[[1]], d[[2]]]]; 
   If[x != 0, total = total + x ; count++]];
  Ceiling[total/N[count]]
  ]

```

When test average with the following parameters,Mathematica returns indeterminations which is something that I don’t want to, look

```
average[Null, {1, 1}, {7, 1}, {4, 4},malla]

```

I think that the problem is. what because Mathematica does not make the comparison of {1,1 } ! =Null,returning only the same input i.e. {1,1 } != Null,  
Is there any way make that run the average function?, if anyone can help me thank you it is in advance, good night all.

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [October 13, 2015, 9:48am UTC](https://community.wolfram.com/t/help-with-null/6925/2 "2015-10-13T09:48:39Z")

</div>

Try writing `x =!= y` (UnsameQ) instead of `x != y` (Unequal).

---

<div class="post-metadata">

**Author:** ![22padrinos](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/22padrinos/32/29645_2.png) [@22padrinos](https://community.wolfram.com/u/22padrinos)\
**Post date:** [October 13, 2015, 7:57pm UTC](https://community.wolfram.com/t/help-with-null/6925/3 "2015-10-13T19:57:16Z")

</div>

Gianluca Gorni, thank you very much for your help, with the solution that gave me it solved my problem, that’s what I needed.

Greetings Luis Ledesma 🙂
