http://imagej.273.s1.nabble.com/Array-deleteElement-within-macro-language-tp5021937p5021942.html
I'm not a macro language user, but I'm curious: how does Array.delete(a1,3) know that the '3' is an index and not a value?
> On Mar 29, 2019, at 11:09, Wayne Rasband <
[hidden email]> wrote:
>
>> On Mar 27, 2019, at 7:06 AM, Philippe CARL <
[hidden email]> wrote:
>>
>> Dear all,
>>
>> Would there be an interest for having an "Array.deleteElement(array, index)"
>> entry within the macro language methods?
>
> Thanks to Norbert Vischer, the ImageJ 1.52o7 daily build adds an Array.delete(array,value) macro function that can be used to delete array elements by value or by index.
>
> Here is an example:
>
> // delete using a value
> a1 = Array.getSequence(10);
> Array.reverse(a1);
> without3 = Array.delete(a1, 3);
>
> // delete using indexes
> a2 = Array.getSequence(10);
> a22 = Array.copy(a2);
> a22[5] = NaN;
> a22[6] = NaN;
> without5and6 = Array.delete(a22, NaN);
>
> // delete using string value
> a3= newArray("one", "two", "three", "four");
> withoutTwo = Array.delete(a3, "two");
>
> Array.show(a1, without3, a2, without5and6, a3, withoutTwo);
>
> -wayne
>
>
>> Such deletion could be performed with the code below, but could not be too
>> easy to figure out:
>>
>> function ArrayDeleteElement(array, index)
>>
>> {
>>
>> return Array.concat(Array.slice(array, 0,
>> index - 1), Array.slice(array, index, array.length));
>>
>> }
>>
>> My best regards,
>>
>> Philippe
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html