On Sun, 24 Oct 2010 13:02:24 +0200, Adam Cigánek wrote:
> Hello,
>
> Is there a function in the standard library to delete an element from an
> array (or range)? Something like:
>
> auto a = [1, 2, 3, 4, 5, 6];
> auto b = delete(a, 4);
>
> assert([1, 2, 3, 4,
bearophile wrote:
> some buttons of your GUI
I doubt that one wants to _delete_ buttons of a GUI instead of inactivating
them and the OP did ask for "a function in the standard library to delete
an element from an array", i.e. arrays without any restrictions on the
number o
spir:
> Bearophile, what do you mean with "arrays dynamic to the right"? (that they
> extend/compress (only) on the right side?)
In Python you may add items at the start too of a list, but that's not an
efficient operation, Python lists are amortized efficient only if you append
items to their
> Your new example doesn't show it better, it's the only one you've given that
> shows it at all. What you had originally was
>
> auto a = [1, 2, 3, 4, 5, 6];
> auto b = delete(a, 4);
>
> assert([1, 2, 3, 4, 6] == b);
>
> which shows the removal of the element at index 4, not the element with
>
On Sun, 24 Oct 2010 14:47:43 -0400
bearophile wrote:
> Manfred_Nowak:
>
> > arrays are computational not well suited for deleting elements, nor are
> > lists.
Sequences of all kinds are the worst possible kind of collection for this
operation (not only linear search, but shift all elements pl
spir:
> In my opinion, such non-obvious complications are good reasons to have
> seemingly trivial operations implemented as builtin routines. (and should
> throw error in case of failure)
std.algorithm.delete contains code like if(rEnd == range.length), so if you
give it a signed integer comi
Manfred_Nowak:
> arrays are computational not well suited for deleting elements, nor are
> lists.
On the other hand dynamic arrays are handy for many other purposes. So if you
have just 20 items, like some buttons of your GUI, you may want to use a
dynamic array to add and remove them, especia
Adam Cigánek wrote:
> Is there a function in the standard library to delete an element from
> an array (or range)?
arrays are computational not well suited for deleting elements, nor are
lists.
-manfred
On 24/10/2010 12:24, Adam Cigánek wrote:
remove removes element at a given offset. I want to remove element
with a given value. This is example shows it better:
Your new example doesn't show it better, it's the only one you've given
that shows it at all. What you had originally was
auto
On Sun, 24 Oct 2010 15:51:29 +0200
Adam Cigánek wrote:
> > In my opinion, such non-obvious complications are good reasons to have
> > seemingly trivial operations implemented as builtin routines. (and should
> > throw error in case of failure)
>
> Or have them in the standard library - better
> In my opinion, such non-obvious complications are good reasons to have
> seemingly trivial operations implemented as builtin routines. (and should
> throw error in case of failure)
Or have them in the standard library - better for keeping the language small.
adam.
>
>
> Denis
> -- -- -- -- -
On Sun, 24 Oct 2010 09:31:12 -0400
bearophile wrote:
> Jonathan M Davis:
>
> > Well, then use indexOf() to get the offset and remove() to remove the
> > element.
>
> But you must test the result value of indexOf, because it returns -1 (a
> signed value, probably an integer, not a signed word,
Jonathan M Davis:
> Well, then use indexOf() to get the offset and remove() to remove the element.
But you must test the result value of indexOf, because it returns -1 (a signed
value, probably an integer, not a signed word, so it may give troubles on 64
bit systems) when the item is missing. T
> Well, then use indexOf() to get the offset and remove() to remove the element.
>
Yes, that's what I'm doing. I just thought that I maybe overlook such
function in the standard library. So there is none. No problem, I'll
keep using my own. Still think it would be useful to add it, because I
belie
uot;);
>
> assert(["foo", "baz"] == b);
>
>
> adam.
>
> 2010/10/24 Simen kjaeraas :
> > On Sun, 24 Oct 2010 13:02:24 +0200, Adam Cigánek
> >
> > wrote:
> >> Hello,
> >>
> >> Is there a function in t
Simen kjaeraas :
> On Sun, 24 Oct 2010 13:02:24 +0200, Adam Cigánek
> wrote:
>
>> Hello,
>>
>> Is there a function in the standard library to delete an element from
>> an array (or range)? Something like:
>>
>> auto a = [1, 2, 3, 4, 5, 6];
>> aut
On Sun, 24 Oct 2010 13:02:24 +0200, Adam Cigánek
wrote:
Hello,
Is there a function in the standard library to delete an element from
an array (or range)? Something like:
auto a = [1, 2, 3, 4, 5, 6];
auto b = delete(a, 4);
assert([1, 2, 3, 4, 6] == b);
I've noticed the
Hello,
Is there a function in the standard library to delete an element from
an array (or range)? Something like:
auto a = [1, 2, 3, 4, 5, 6];
auto b = delete(a, 4);
assert([1, 2, 3, 4, 6] == b);
I've noticed there is eliminate in std.algorithm, which seems to be
doing just that
18 matches
Mail list logo