Closed 0rir closed 1 year ago
If I understand it correctly, you want it to produce the ordinal numbers of any matches?
Could you give some code examples and expected result?
I figure it's about the list case of min
, so [4,1,2,-6,10].min(:k)
would evaluate to 3
, the index of the minimum element. While it's not mentioned, I imagine :kv
and :p
are implied by this request too.
@lizmat, @jnthn, you both are entirely correct in what you say.
I would have done better to reference @a.first( @a.min)
as :end
is also applicable.
And I guess if there are multiple minimum / maximum values, it would produce multiple indices.
@0rir I'm not sure how :end
comes into play here?
And I guess if there are multiple minimum / maximum values, it would produce multiple indices.
Only if min
/max
have an option to do that already; otherwise, I'd keep it consistent with the value result.
My thinking was to keep the return to the value element, the index or both in a Pair
.
Putting my hand up as someone who has wanted min
/max
with :k
.
The adverbs named args should be similar to first
, ie. :v
just returns the value (default), :k
returns the index, :kv
returns a Seq of the index and value, and :p
returns a Pair of the index and value.
Implemented .min
/ .max
with :k
, :v
, :kv
and :p
adverbs with https://github.com/rakudo/rakudo/commit/ec0007729d
So that these arguments brought up on IRC are preserved.
The "wrong" with them is that
Please keep in mind that since a custom predicate could be used for determining extreme values, there could be different values that are all the minimums/maximums of a certain list of values and hence retrieving not just one but all of them at once would surely make sense on its own as well.
At which point I would ask: actually, why not have a flag for min
and max
for retrieving all minimum/maximum values? In which case minpairs
and maxpairs
would immediately stand out as the ad-hoc redundant alternative.
Yesterday I've implemented :k
, :v
, :kv
and :p
on .min
and .max
.
:v
is effectively: give me all minimum / maximum values.
This is feature request for the addition of a
:k
option for appropriate types;map
being the model.