ArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2015-03-09T16:50:25+02:00 https://brainmodular.com/forums/app.php/feed/topic/4737 2015-03-09T16:50:25+02:00 2015-03-09T16:50:25+02:00 https://brainmodular.com/forums/viewtopic.php?t=4737&p=31546#p31546 <![CDATA[FastScript - Find index of smallest number in an Array]]>
Yes I agree that the name should be changed from oldest to lowest for a generic.

In my specific script I created a Dynamic Channelization, so for the procedure I am trying to actually determine the note that has stayed in the array the longest.
If all channel slots are empty, I purge the oldest one to make room for the next.

It is actually working quite nice now, I have been working on implementing scala tuning into Hollyhock. As of now, I have a format that does direct Frequency output, I am now working on the MIDI pitchbend. Once finished my goal is to provide Alternate tunings not only for single notes, but for chords.

-S

Statistics: Posted by sephult — 09 Mar 2015, 15:50


]]>
2015-03-09T15:42:50+02:00 2015-03-09T15:42:50+02:00 https://brainmodular.com/forums/viewtopic.php?t=4737&p=31545#p31545 <![CDATA[FastScript - Find index of smallest number in an Array]]>
It looks a bit more obvious (to me, at least) if the variable name is changed from "oldest" to "lowest" or something similar.

Statistics: Posted by bsork — 09 Mar 2015, 14:42


]]>
2015-03-09T14:35:43+02:00 2015-03-09T14:35:43+02:00 https://brainmodular.com/forums/viewtopic.php?t=4737&p=31544#p31544 <![CDATA[FastScript - Find index of smallest number in an Array]]>
I was getting totally stumped for a moment. Below is the code that is working for me now.
Was there any reason why you started the array index as 1, or was this just a mistake? Had me curious.

CODE:

  oldest&#58;=0; //Initialize for detecting oldest index                           for k&#58;=0 to getarraylength&#40;order_array&#41;-1 do begin                                                    if &#40;order_array&#91;k&#93; < order_array&#91;oldest&#93;&#41; then                 oldest &#58;= k;                                                                                end;
Again, Thank you Bsork!!

Best Regards,

-S

Statistics: Posted by sephult — 09 Mar 2015, 13:35


]]>
2015-03-09T09:31:04+02:00 2015-03-09T09:31:04+02:00 https://brainmodular.com/forums/viewtopic.php?t=4737&p=31540#p31540 <![CDATA[FastScript - Find index of smallest number in an Array]]>
You could do eg:

CODE:

oldest &#58;= 0;FOR k &#58;= 1 TO &#40;ARRAY_LENGTH - 1&#41; DO BEGIN  IF &#40;order_array&#91;k&#93; < order_array&#91;oldest&#93;&#41; THEN     oldest &#58;= k;END;

Statistics: Posted by bsork — 09 Mar 2015, 08:31


]]>
2015-03-08T17:33:29+02:00 2015-03-08T17:33:29+02:00 https://brainmodular.com/forums/viewtopic.php?t=4737&p=31534#p31534 <![CDATA[FastScript - Find index of smallest number in an Array]]>
So I have run into a problem at the moment I cannot wrap my head around.

I need to find the index of the smallest number in an Array, I know in several programming languages there are functions to do this.
I thought this was quite an easy thing to do and I have done before in other languages, however I am starting to become stumped (probably just finding a downfall of pascal??).
Definitely wasn't expecting to get hung-up by this.

So below my solution was a simple conditional check within a For loop. If smaller than the variable then make the variable equal to the iteration/index.
Keep checking for smaller numbers. However, the result of oldest is always Zero even when the smallest number exists in [1].

So Process procedure decides and receives the event trigger, if a condition exists secondary procedures are executed which contain this code below.
The variable oldest is a value from 1 to 16.

Anyone have a clue as to why this may be, or have some guidance to an alternative method to perform this?

CODE:

  oldest&#58;=17; //Initialize for detecting oldest index              //Search for lowest number in array and purge                for k&#58;=0 to 15 do begin                 if order_array&#91;k&#93; < oldest then begin                  oldest &#58;= k;                           end;
end;


-S

Statistics: Posted by sephult — 08 Mar 2015, 16:33


]]>
BrainModular BrainModular Users Forum 2015-03-09T16:50:25+02:00 https://brainmodular.com/forums/app.php/feed/topic/4737 2015-03-09T16:50:25+02:00 2015-03-09T16:50:25+02:00 https://brainmodular.com/forums/viewtopic.php?t=4737&p=31546#p31546 <![CDATA[FastScript - Find index of smallest number in an Array]]>
Yes I agree that the name should be changed from oldest to lowest for a generic.

In my specific script I created a Dynamic Channelization, so for the procedure I am trying to actually determine the note that has stayed in the array the longest.
If all channel slots are empty, I purge the oldest one to make room for the next.

It is actually working quite nice now, I have been working on implementing scala tuning into Hollyhock. As of now, I have a format that does direct Frequency output, I am now working on the MIDI pitchbend. Once finished my goal is to provide Alternate tunings not only for single notes, but for chords.

-S

Statistics: Posted by sephult — 09 Mar 2015, 15:50


]]>
2015-03-09T15:42:50+02:00 2015-03-09T15:42:50+02:00 https://brainmodular.com/forums/viewtopic.php?t=4737&p=31545#p31545 <![CDATA[FastScript - Find index of smallest number in an Array]]>
It looks a bit more obvious (to me, at least) if the variable name is changed from "oldest" to "lowest" or something similar.

Statistics: Posted by bsork — 09 Mar 2015, 14:42


]]>
2015-03-09T14:35:43+02:00 2015-03-09T14:35:43+02:00 https://brainmodular.com/forums/viewtopic.php?t=4737&p=31544#p31544 <![CDATA[FastScript - Find index of smallest number in an Array]]>
I was getting totally stumped for a moment. Below is the code that is working for me now.
Was there any reason why you started the array index as 1, or was this just a mistake? Had me curious.

CODE:

  oldest&#58;=0; //Initialize for detecting oldest index                           for k&#58;=0 to getarraylength&#40;order_array&#41;-1 do begin                                                    if &#40;order_array&#91;k&#93; < order_array&#91;oldest&#93;&#41; then                 oldest &#58;= k;                                                                                end;
Again, Thank you Bsork!!

Best Regards,

-S

Statistics: Posted by sephult — 09 Mar 2015, 13:35


]]>
2015-03-09T09:31:04+02:00 2015-03-09T09:31:04+02:00 https://brainmodular.com/forums/viewtopic.php?t=4737&p=31540#p31540 <![CDATA[FastScript - Find index of smallest number in an Array]]>
You could do eg:

CODE:

oldest &#58;= 0;FOR k &#58;= 1 TO &#40;ARRAY_LENGTH - 1&#41; DO BEGIN  IF &#40;order_array&#91;k&#93; < order_array&#91;oldest&#93;&#41; THEN     oldest &#58;= k;END;

Statistics: Posted by bsork — 09 Mar 2015, 08:31


]]>
2015-03-08T17:33:29+02:00 2015-03-08T17:33:29+02:00 https://brainmodular.com/forums/viewtopic.php?t=4737&p=31534#p31534 <![CDATA[FastScript - Find index of smallest number in an Array]]>
So I have run into a problem at the moment I cannot wrap my head around.

I need to find the index of the smallest number in an Array, I know in several programming languages there are functions to do this.
I thought this was quite an easy thing to do and I have done before in other languages, however I am starting to become stumped (probably just finding a downfall of pascal??).
Definitely wasn't expecting to get hung-up by this.

So below my solution was a simple conditional check within a For loop. If smaller than the variable then make the variable equal to the iteration/index.
Keep checking for smaller numbers. However, the result of oldest is always Zero even when the smallest number exists in [1].

So Process procedure decides and receives the event trigger, if a condition exists secondary procedures are executed which contain this code below.
The variable oldest is a value from 1 to 16.

Anyone have a clue as to why this may be, or have some guidance to an alternative method to perform this?

CODE:

  oldest&#58;=17; //Initialize for detecting oldest index              //Search for lowest number in array and purge                for k&#58;=0 to 15 do begin                 if order_array&#91;k&#93; < oldest then begin                  oldest &#58;= k;                           end;
end;


-S

Statistics: Posted by sephult — 08 Mar 2015, 16:33


]]>