[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Similarity Clumping



a = [0.4, 0.42, 0.45, 0.46, 0.6, 0.7];
b = a.separate { |a, b| (b - a) >= 0.02 };



> On 30 Nov 2019, at 6:15am, jables.deutsch@xxxxxxxxx wrote:
> 
> Hi all -
> 
> I'd like to take an array and break it into sub-arrays, based on the difference between values.. It might be easier to illustrate:
> 
> I have an array: 
> a = [0.4, 0.42, 0.45, 0.46, 0.6, 0.7];
> And I want to set a threshold of difference - in this case: 0.02.
> newArray = [[0.4, 0.42], [0.45, 0.46], [0.6], [0.7]];
> 
> Is there a function that does this kind of sorting intrinsically?  Can anyone suggest an approach?
> 
> 
> 
> 
> 


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/