On 2/8/23 23:19, Alexander Zhirov wrote:
>> foo.byPair
>> .array
>> .sort!((a, b) => a.key < b.key)
>> .map!(a => a.value);
>
> Is it possible to specify in `map` to return the result `[a.key] =
> a.value`? To make the result look like `[key:[val], key:[val]]`
map can return a tuple and
On Thursday, 9 February 2023 at 07:19:08 UTC, Alexander Zhirov
wrote:
foo.byPair
.array
.sort!((a, b) => a.key < b.key)
.map!(a => a.value);
Is it possible to specify in `map` to return the result
`[a.key] = a.value`? To make the result look like `[key:[val],
key:[val]]`
Wow. This is an
foo.byPair
.array
.sort!((a, b) => a.key < b.key)
.map!(a => a.value);
Is it possible to specify in `map` to return the result `[a.key]
= a.value`? To make the result look like `[key:[val], key:[val]]`
On Tuesday, 27 August 2019 at 20:35:16 UTC, bachmeier wrote:
On Tuesday, 27 August 2019 at 20:14:21 UTC, Machine Code wrote:
It isn't really hard:
It really is hard. foo.byPair.array.sort!((a, b) => a.key <
b.key).map!(a => a.value); is a lot to digest for someone
learning the language.
On Tuesday, 27 August 2019 at 16:25:00 UTC, Samir wrote:
As I've mentioned on the list before, I really struggle to
understand how some of the std.algorithm functions such as
`map` work when combined with things like `array`, `sort` and
especially `zip` but really appreciate the support I find
On Tuesday, 27 August 2019 at 20:14:21 UTC, Machine Code wrote:
It isn't really hard:
It really is hard. foo.byPair.array.sort!((a, b) => a.key <
b.key).map!(a => a.value); is a lot to digest for someone
learning the language. There's a big difference between not being
hard for someone
On Tuesday, 27 August 2019 at 16:25:00 UTC, Samir wrote:
On Sunday, 25 August 2019 at 17:01:23 UTC, a11e99z wrote:
auto foo = ["VXE":8, "BZP":5, "JLC":2];
foo.byPair.array.sort!"a[0]
On Sunday, 25 August 2019 at 19:03:10 UTC, JN wrote:
I think normal lambdas are better than these string ones:
On Sunday, 25 August 2019 at 17:01:23 UTC, a11e99z wrote:
auto foo = ["VXE":8, "BZP":5, "JLC":2];
foo.byPair.array.sort!"a[0]
On Sunday, 25 August 2019 at 19:03:10 UTC, JN wrote:
I think normal lambdas are better than these string ones:
foo.byPair.array.sort!((a, b) => a[0] < b[0]).map!(a =>
On Sunday, 25 August 2019 at 19:03:10 UTC, JN wrote:
I think normal lambdas are better than these string ones:
foo.byPair.array.sort!((a, b) => a[0] < b[0]).map!(a =>
a[1]).writeln;
You can also use names instead of numeric indices:
foo.byPair.array.sort!((a, b) => a.key < b.key).map!(a =>
On Sunday, 25 August 2019 at 17:01:23 UTC, a11e99z wrote:
On Sunday, 25 August 2019 at 16:54:33 UTC, Samir wrote:
Is there a way to output the values of an associative array
based on the lexicographic order of the keys?
For example, if foo = ["VXE":8, "BZP":5, "JLC":2], I'd like to
output
On Sunday, 25 August 2019 at 16:54:33 UTC, Samir wrote:
Is there a way to output the values of an associative array
based on the lexicographic order of the keys?
For example, if foo = ["VXE":8, "BZP":5, "JLC":2], I'd like to
output something like:
5
2
8
auto foo = ["VXE":8, "BZP":5,
Is there a way to output the values of an associative array based
on the lexicographic order of the keys?
For example, if foo = ["VXE":8, "BZP":5, "JLC":2], I'd like to
output something like:
5
2
8
Thanks!
Samir
What is the best way to have a function sort an associative array
by key? The following yields a conversion error.
double[string] aa_sort(double[string] aa) {
return aa.keys.sort;
}
On 11/23/12, dsmith d...@nomail.com wrote:
What is the best way to have a function sort an associative array
by key? The following yields a conversion error.
double[string] aa_sort(double[string] aa) {
return aa.keys.sort;
}
Hashes are unordered, you can't sort them by key because
On 11/23/2012 07:09 PM, dsmith wrote:
What is the best way to have a function sort an associative array by
key? The following yields a conversion error.
double[string] aa_sort(double[string] aa) {
return aa.keys.sort;
}
A hash table is unsorted by definition. What is it that you want
On Friday, 23 November 2012 at 18:24:07 UTC, Timon Gehr wrote:
On 11/23/2012 07:09 PM, dsmith wrote:
What is the best way to have a function sort an associative
array by
key? The following yields a conversion error.
double[string] aa_sort(double[string] aa) {
return aa.keys.sort
On 11/23/2012 07:48 PM, dsmith wrote:
On Friday, 23 November 2012 at 18:24:07 UTC, Timon Gehr wrote:
On 11/23/2012 07:09 PM, dsmith wrote:
What is the best way to have a function sort an associative array by
key? The following yields a conversion error.
double[string] aa_sort(double[string
17 matches
Mail list logo