![]() |
![]() ![]() ![]() ![]() ![]()
|
next newest topic | next oldest topic |
Author | Topic: sorting arrays with hot parameters | |
Phi Curtis Member |
![]() ![]() ![]() Hi, Continuing on a theme from another recent thread about having variables/hot parameters inside literal arrays (and how that isn't possible in Capytalk): I would like to sort an array of hot values from high to low. Taking advantage of the sorted array collection type, his smalltalk code works:
code: !Index will then pull up the numbers in the correct (low to high) order. But the expression wont work with hot values in the array. Is there a way to somehow use the sorted array with hot values? I'm sure there's a more labor-intensive way to do this with comparison operators, but thought I would ask first. IP: Logged | |
SSC Administrator |
![]() ![]() ![]() Hi Phil, What is the result you are trying to achieve? Are you looking for the maximum/minimum value of several faders? Or are they checkboxes (Booleans)? What is the reason you are sorting the hot values? If you could please describe the result, we might be able to suggest some ways of accomplishing this using CapyTalk. Thanks! BTW, just to clarify, asSortedCollection is a Smalltalk (not a CapyTalk) message. You cannot use Smalltalk to sort an Array of variables whose values are not yet known (or could change after the sorting). Because to put an element into its correctly sorted position, it must have a value so you can test whether that value is greater than or less than that of the other elements. Hot values can change while the Sound is playing but in your example, you are doing the sorting before the Sound even starts playing (all Smalltalk is executed before the Sound starts to play; it is only CapyTalk expressions that are evaluated while the Sound is playing).
quote: I think the statement was rather that no language can use variables in a literal Array. That's just a matter of definition. The term 'literal' in this context means that all the elements are constants (in Smalltalk, those can be Strings, Characters, Symbols, or Numbers). Smalltalk provides a shortcut for creating literal Arrays. But it does not prevent you from creating Arrays of any objects, including variables. As I stated in that thread, Smalltalk Arrays can contain any objects (including other Arrays), when you create them using the Array's instance creation methods or, as Luddy suggested, using the collect: method, or by adding one element at a time in a loop (after the Array has been created and dimensioned). IP: Logged | |
Phi Curtis Member |
![]() ![]() ![]() quote: I realized after I sent the message...I guess what I would need is a mechanism that re-evaluates and resorts the array every time the values of the members of the array change. I know it would be very easy to find the highest or lowest member of the array (using vmin: or vmax: and just going through the entire array member by member), but how would you find the second lowest, for example? IP: Logged | |
Phi Curtis Member |
![]() ![]() ![]()
I'm curious if there would be a way to construct iteratively it so that all you had to give was the number of hot values and the names of the hot values, and it would generate the array for you. IP: Logged | |
ChristianSchloesser Member |
![]() ![]() ![]() quote: Did anybody ever found out a way to do that? [This message has been edited by ChristianSchloesser (edited 21 December 2013).] IP: Logged | |
SSC Administrator |
![]() ![]() ![]() Would you like the min and the max? (or do you need the entire array sorted)? IP: Logged | |
ChristianSchloesser Member |
![]() ![]() ![]() I really would like to sort the entire array of !HotValues if one of the !HotValues changes. IP: Logged |
All times are CT (US) | next newest topic | next oldest topic |
![]() ![]() |
This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.