How to check if a singleton exists in a vector

Discuss Lemur and share techniques.
Post Reply
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

How to check if a singleton exists in a vector

Post 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?
electrofux
Regular
Posts: 294
Joined: 24 Jan 2012 18:22

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

Post by electrofux »

Not sure if there is a dedicated function for this but i would just loop through it.
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

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

Post by Softcore »

Hear ya! Thanks for the reply....I found a workaround to what I wanted to achieve so all is well.
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

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

Post 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
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