# New function suggestion: Dont

**URL:** <https://community.wolfram.com/t/new-function-suggestion-dont/8834>\
**Category:** Ideas\
**Tags:** ruliology, software-development, equation-solving\
**Created:** [July 4, 2016, 3:10pm UTC](https://community.wolfram.com/t/new-function-suggestion-dont/8834 "2016-07-04T15:10:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rowland](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/rowland/32/36108_2.png) [@rowland](https://community.wolfram.com/u/rowland)\
**Post date:** [July 4, 2016, 3:10pm UTC](https://community.wolfram.com/t/new-function-suggestion-dont/8834/1 "2016-07-04T15:10:22Z")

</div>

In the spirit of using WL to talk to AI, this function should be useful, It is like  
[Do](http://reference.wolfram.com/language/ref/Do.html)  
except it tells the program what not to do.

A simple example might be

```
Dont[Outer[Divide, Range[-5,5], Range[-5,5]], DivideByZero]

```

There are versions already in the language, like when you solve a differential equation you can stop it under some conditions, and of course there is [Break](http://reference.wolfram.com/language/ref/Break.html).

One might think this is silly but because of [computational irreducibility](http://www.wolframscience.com/nksonline/page-737) it is impossible to always predict when something bad will happen.

 ![code38.jpg](https://global.discourse-cdn.com/wolfram/original/2X/d/dfea2b08349a9ec7d5fe8d5a2712d506165fc62b.jpeg)

---

<div class="post-metadata">

**Author:** ![karanprime](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/karanprime/32/21935_2.png) [@karanprime](https://community.wolfram.com/u/karanprime)\
**Post date:** [July 4, 2016, 3:13pm UTC](https://community.wolfram.com/t/new-function-suggestion-dont/8834/2 "2016-07-04T15:13:38Z")

</div>

Is this why Wolfram Language has no Try clause?  
Because Do || Don’t, !?Try ?

---

<div class="post-metadata">

**Author:** ![johnburnette](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@johnburnette](https://community.wolfram.com/u/johnburnette)\
**Post date:** [July 4, 2016, 6:57pm UTC](https://community.wolfram.com/t/new-function-suggestion-dont/8834/3 "2016-07-04T18:57:00Z")

</div>

+1 for the Yoda reference.

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [July 5, 2016, 12:56pm UTC](https://community.wolfram.com/t/new-function-suggestion-dont/8834/4 "2016-07-05T12:56:23Z")

</div>

But what should it return then for those cases?

```
Didnt[DivideByZero] ?

```

---

<div class="post-metadata">

**Author:** ![rowland](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/rowland/32/36108_2.png) [@rowland](https://community.wolfram.com/u/rowland)\
**Post date:** [July 5, 2016, 3:52pm UTC](https://community.wolfram.com/t/new-function-suggestion-dont/8834/5 "2016-07-05T15:52:02Z")

</div>

Good question Sander. It could be Inactive code taking the place whenever the execution tries code which matches the Don’t pattern.

There could be an expression evaluated, like [Check](https://reference.wolfram.com/language/ref/Check.html) which returns something when a message is generated, but evaluate it in place inside the expression. Another analogy is with the optional second argument to [Dynamic](https://reference.wolfram.com/language/ref/Dynamic.html). which evaluates when a variable changes its value.

In order to give a concrete answer,

```
Dont[Table[2/i, {i,-2,2}], DivideByZero]

```

might return

```
{-1 -1/2, Inactive[Divide][2,0], 1/2, 1}

```

---

<div class="post-metadata">

**Author:** ![kubapod](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/kubapod/32/18662_2.png) [@kubapod](https://community.wolfram.com/u/kubapod)\
**Post date:** [July 5, 2016, 6:27pm UTC](https://community.wolfram.com/t/new-function-suggestion-dont/8834/6 "2016-07-05T18:27:20Z")

</div>

Here is an example, creating function from it won’t be easy if it is meant to be general, but is certainly possible:

```
Internal`InheritedBlock[{Divide},
   Unprotect@Divide;
   Divide[x_, 0] := Inactive[Divide][x, 0];
   Outer[Divide, Range[-1, 1], Range[-1, 1]]
 ]

```

> {{1, Inactive[Divide][-1, 0], -1}, {0, Inactive[Divide][0, 0], 0}, {-1, Inactive[Divide][1, 0], 1}}
