How to check if a singleton exists in a vector

Discuss Lemur and share techniques.
Post Reply
Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34
How to check if a singleton exists in a vector

Post by Softcore » 13 Jan 2014 20:16

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?

electrofux
Regular
Posts:297
Joined:24 Jan 2012 18:22

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

Post by electrofux » 13 Jan 2014 23:58

Not sure if there is a dedicated function for this but i would just loop through it.

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

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

Post by Softcore » 14 Jan 2014 15:21

Hear ya! Thanks for the reply....I found a workaround to what I wanted to achieve so all is well.

Macciza
Regular
Posts:1325
Joined:07 Dec 2011 04:57
Location:Sydney, Australia.

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

Post by Macciza » 15 Jan 2014 04:58

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
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]

Post Reply