Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Handling conditions on subvector elements
Replies: 6   Last Post: Mar 23, 2011 3:03 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Lengyel Tamas

Posts: 10
Registered: 2/23/11
Handling conditions on subvector elements
Posted: Mar 22, 2011 5:21 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Dear Mathworld users,

I am struggling with a piece of code which should result in a List :

1) I have a vector with subvectors with triplets of values.
2) What I wish to achieve is a cycle that returns with a List with either
'1's or '2's in it.
3) The cycle should check whether the first and second element in
subvectors are equal and neither of them are equal with the third, if so,
return 1;
If all the elements are unequal, return 2

E.g.

V= {{1,1,2},{1,1,3},{2,3,1},{1,2,3},{3,3,1}} should return with {1, 1, 2,
2,1}

I'm assuming 'If' should be the key (as it returns 2 types of values), but
I can't seem to do it properly.

Thank you in advance

Tamas




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.