On Saturday, 15 January 2022 at 06:43:05 UTC, forkit wrote:
On Saturday, 15 January 2022 at 03:48:41 UTC, Steven
Schveighoffer wrote:
int[][] arrayOfArrays = iota(1,16).
array.chunks(5).array;
-Steve
All answers were helpful ;-)
But I like this one the best,
because I find it both easier
On Saturday, 15 January 2022 at 03:48:41 UTC, Steven
Schveighoffer wrote:
Alternatively (with only one allocation for the int[] data):
```d
int[][] arrayOfArrays = iota(1, 16).array.chunks(5).array;
```
-Steve
All answers were helpful ;-)
But I like this one the best, because I find it
On 1/14/22 9:41 PM, Paul Backus wrote:
On Saturday, 15 January 2022 at 01:49:14 UTC, forkit wrote:
I want int[][] like this -> [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11,
12, 13, 14, 15]]
Any help will be appreciated.
note: to2Darray is not a valid statement ;-)
// ---
module test;
import
On Sat, Jan 15, 2022 at 01:49:14AM +, forkit via Digitalmars-d-learn wrote:
[...]
> int[][] arrayOfarrays = iota(1, 16).chunks(5).to2Darray; // how to
> convert this into [][]
[...]
auto arrayOfArrays = iota(1, 16).chunks(5).map!(r => r.array).array;
T
--
Winners never quit,
On Saturday, 15 January 2022 at 02:41:08 UTC, Paul Backus wrote:
import std.algorithm: map;
import std.array: array;
int[][] arrayOfArrays = iota(1, 16).chunks(5).map!array.array;
oh. thanks!
also it seems I reposted the same question (didn't realise this
one got posted)
On Saturday, 15 January 2022 at 03:18:21 UTC, forkit wrote:
oops. ignore this - was a repost of another post that I thought
never got posted ;-)
I want to do the equivalent of this:
int[][] arrayOfarrays = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11,
12, 13, 14, 15]];
But getting the initialiser values using iota and chunks instead.
Any help will be appreciated.
note: to2Darray is not a valid statement ;-)
// ---
module test;
import
On 1/14/22 6:10 PM, Jaime wrote:
Why does this happen? Is it intended behavior? I'm still somewhat new to
D, so I'm not prepared to submit this as an issue quite yet; for all I
know, there might be a good reason it works this way.
This seems like a bug to me.
This confusing problem really
On Saturday, 15 January 2022 at 01:49:14 UTC, forkit wrote:
I want int[][] like this -> [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10],
[11, 12, 13, 14, 15]]
Any help will be appreciated.
note: to2Darray is not a valid statement ;-)
// ---
module test;
import std;
void main()
{
int[][]
I want int[][] like this -> [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10],
[11, 12, 13, 14, 15]]
Any help will be appreciated.
note: to2Darray is not a valid statement ;-)
// ---
module test;
import std;
void main()
{
int[][] arrayOfarrays = iota(1, 16).chunks(5).to2Darray; //
how to convert
Some code that produces the strange behavior I'm seeing:
```d
shared class MyClass {
this() {}
this(As...)(As args) if (As.length > 0) {}
}
void main() {
pragma(msg, typeof(new MyClass));
pragma(msg, typeof(new MyClass(1, 2, 3, "hello world")));
pragma(msg, typeof(new
On Friday, 14 January 2022 at 17:56:48 UTC, Adam D Ruppe wrote:
On Friday, 14 January 2022 at 17:48:41 UTC, kyle wrote:
[...]
alias works in term of compile-time names, not values. This
means the `this` value, being run time, gets discarded.
[...]
Thanks Adam. We need a repository of
On Friday, 14 January 2022 at 17:48:41 UTC, kyle wrote:
I'm trying to use ```alias``` in an operator overload to reduce
typing, but what gets aliased is not what I expect.
alias works in term of compile-time names, not values. This means
the `this` value, being run time, gets discarded.
I'm trying to use ```alias``` in an operator overload to reduce
typing, but what gets aliased is not what I expect. Tested in DMD
v2.098.1-dirty on Windows plus whatever versions of DMD, GDC, and
LDC I have installed on Linux. Thanks.
```
struct Broke
{
double num;
import std.traits
14 matches
Mail list logo