Re: [PHP-DEV] [RFC] [Discussion] Add new function `array_group`

2023-06-01 Thread Boro Sitnikovski
> On 1.6.2023, at 09:18, Casper Langemeijer wrote: > > On Thu, Jun 1, 2023, at 01:19, Boro Sitnikovski wrote: >> Thank you for the information and encouragement! I was a bit scared of this >> one being rejected too, but still decided to give it a shot :) > > As a

Re: [PHP-DEV] [RFC] [Discussion] Add new function `array_group`

2023-05-31 Thread Boro Sitnikovski
> On 1.6.2023, at 01:13, Levi Morrison wrote: > > On Tue, May 30, 2023 at 5:35 AM Boro Sitnikovski wrote: >> >> Hello all, >> >> As per the How To Create an RFC instructions, I am sending this e-mail in >> order to get your feedback on my proposal.

Re: [PHP-DEV] [RFC] [Discussion] Add new function `array_group`

2023-05-31 Thread Boro Sitnikovski
> On 1.6.2023, at 00:59, Larry Garfield wrote: > > On Wed, May 31, 2023, at 10:47 PM, Boro Sitnikovski wrote: > >> 1. The grouping that JavaScript/.NET/Lodash/Scala/etc. do (this should >> be the default of `array_group`) >> 2. The grouping that Haskell does, th

[PHP-DEV] Re: [RFC] [Discussion] Add new function `array_group`

2023-05-31 Thread Boro Sitnikovski
On 30.5.2023, at 15:13, Boro Sitnikovski wrote:Updated the patch: added a test about increasing subsequences example, and a minor bugfix.On 30.5.2023, at 13:34, Boro Sitnikovski wrote:Hello all,As per the How To Create an RFC instructions, I am sending this e-mail in order to get your feedback

Re: [PHP-DEV] [RFC] [Discussion] Add new function `array_group`

2023-05-31 Thread Boro Sitnikovski
> On 31.5.2023, at 09:03, naitsi...@e.mail.de wrote: > > > > Am 30-May-2023 18:34:19 +0200 schrieb andr...@dqxtech.net: >> On Tue, 30 May 2023 at 18:27, Boro Sitnikovski wrote: >>> >>> Hi, >>> >>> Thank you for your thoughts. >

Re: [PHP-DEV] [RFC] [Discussion] Add new function `array_group`

2023-05-30 Thread Boro Sitnikovski
> On 30.5.2023, at 21:56, Andreas Hennings wrote: > > On Tue, 30 May 2023 at 19:25, Boro Sitnikovski wrote: >> >> Here's some more examples: >> >> 1. Use `array_group` to create list of singleton list: >> ``` >> $groups = array_gr

Re: [PHP-DEV] [RFC] [Discussion] Add new function `array_group`

2023-05-30 Thread Boro Sitnikovski
> On 30.5.2023, at 19:21, Larry Garfield wrote: > > On Tue, May 30, 2023, at 4:27 PM, Boro Sitnikovski wrote: >> Hi, >> >> Thank you for your thoughts. >> >>> I would say the more common desired behavior is the one in your first >>> example

Re: [PHP-DEV] [RFC] [Discussion] Add new function `array_group`

2023-05-30 Thread Boro Sitnikovski
Hi, > On 30.5.2023, at 18:33, Andreas Hennings wrote: > > On Tue, 30 May 2023 at 18:27, Boro Sitnikovski wrote: >> >> Hi, >> >> Thank you for your thoughts. >> >>> I would say the more common desired behavior is the one in your first >&

Re: [PHP-DEV] [RFC] [Discussion] Add new function `array_group`

2023-05-30 Thread Boro Sitnikovski
heers > Andreas > > > On Tue, 30 May 2023 at 17:08, Boro Sitnikovski wrote: >> >> Hey, >> >> Thanks for the suggestion. >> >> For the previous case in the code, I added these in a Gist to not clutter >> here too much: >> >> 1.

Re: [PHP-DEV] [RFC] [Discussion] Add new function `array_group`

2023-05-30 Thread Boro Sitnikovski
value' => 'baz' ], >> ]; >> >> $groups = array_group( $array, function( $a, $b ) { >> return $a['id'] == $b['id']; >> } ); >> ``` >> >> The disadvantage of the first approach is that we are only limited to using >> equality check, and we cannot group by, say, `<` or other functions. >> Similarly, the advantage of the first approach is that the keys are >> preserved, and elements needn't be consecutive. >> >> In any case, I think a utility function such as `array_group` will be widely >> useful. >> >> Please find attached a patch with a proposed implementation. Curious about >> your feedback. >> >> Best, >> >> Boro Sitnikovski >> -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php

[PHP-DEV] Re: [RFC] [Discussion] Add new function `array_group`

2023-05-30 Thread Boro Sitnikovski
Updated the patch: added a test about increasing subsequences example, and a minor bugfix. array_group.patch Description: Binary data On 30.5.2023, at 13:34, Boro Sitnikovski wrote:Hello all,As per the How To Create an RFC instructions, I am sending this e-mail in order to get your feedback on

[PHP-DEV] [RFC] [Discussion] Add new function `array_group`

2023-05-30 Thread Boro Sitnikovski
b['id'];} );```The disadvantage of the first approach is that we are only limited to using equality check, and we cannot group by, say, `<` or other functions.Similarly, the advantage of the first approach is that the keys are preserved, and elements needn't be consecutive.In any case, I think a utility function such as `array_group` will be widely useful.Please find attached a patch with a proposed implementation. Curious about your feedback.Best,Boro Sitnikovski array_group.patch Description: Binary data