Group Abstract Group Abstract

Message Boards Message Boards

0
|
6.8K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Emulate MatLab functions using Wolfram language?

Posted 6 years ago
Attachments:
POSTED BY: Joshua Champion
2 Replies
Posted 6 years ago

Hi Joshua,

At least one issue with the code is the If condition xlist == Null. It will remain unevaluated unless xlist is Null. So the If will remain unevaluated.

{0, 1, 2, 3, 4, 5} == Null
(* {0, 1, 2, 3, 4, 5} == Null *)

If[{0, 1, 2, 3, 4, 5} == Null, True, False]
(* If[{0, 1, 2, 3, 4, 5} == Null, True, False] *)

Rather than testing for Null, test the Length of the list.

POSTED BY: Rohit Namjoshi

Joshua,

Use SameQ (===) instead of Equal in If. Mathematica can always tell if two items are not the same but Equal is more difficult (read the documentation — it describes this in detail). For example, q is not the same as y but they might be Equal.

Regards

Neil

POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard