Page 1 of 1

How to check if a singleton exists in a vector

Posted: 13 Jan 2014 20:16
by Softcore
I have a randomely produced integer value i that returns me an element A of a vector V with 12 elements (floating numbers).

decl i=round(rand()*11);
decl A=V;

How can I then "check" if the value A exists inside another vector K?


Any suggestions?

Re: How to check if a singleton exists in a vector

Posted: 13 Jan 2014 23:58
by electrofux
Not sure if there is a dedicated function for this but i would just loop through it.

Re: How to check if a singleton exists in a vector

Posted: 14 Jan 2014 15:21
by Softcore
Hear ya! Thanks for the reply....I found a workaround to what I wanted to achieve so all is well.

Re: How to check if a singleton exists in a vector

Posted: 15 Jan 2014 04:58
by Macciza
Hi
Figured you would sort something out ..
This has come up before - there is stuff in SLVector that would help

Various ways tp approach it on whether you want just whether it there, or where it is etc

A==K should return array of 0,1 on whether there is match
so sumof(A==K)>0 will return 0/1 if it matches . . .

Cheers
MM