Message Boards Message Boards

Why do I get Null when using my function?

Posted 9 years ago
POSTED BY: Luis Ledesma
5 Replies
Posted 9 years ago

Thank you Frank,Ii'm going to use Select as you suggested, thanks again,look after ,greetings

POSTED BY: Luis Ledesma
In[9]:= p = Partition[Range[10], 2]

Out[9]= {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}}

In[15]:= Select[p, 3 <= Times @@ # <= 45 &]

Out[15]= {{3, 4}, {5, 6}}
POSTED BY: Frank Kampas

You could use Select to get rid of the Nulls

In[7]:= Select[{2, Null, 3, 4, Null}, # =!= Null &]

Out[7]= {2, 3, 4}

or use Select instead of If to get the results you want, which is probably the better approach.

In[8]:= Select[Range[5], 2 <= # <= 4 &]

Out[8]= {2, 3, 4}
POSTED BY: Frank Kampas
Posted 9 years ago

Hi Frank, thanks for your quick response, now my question is, how do I do this function unless you get the Null? I I thought that was the way to do it, I hope you can help me, greetings

POSTED BY: Luis Ledesma

Null is what you get from your If statement when the criterion isn't satisfied.

In[3]:= If[2 > 3, "yes"] // InputForm

Out[3]//InputForm=
Null
POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract