Thread overview
understanding mir, generic nd array iterator
Sep 10
monkyyy
4 days ago
monkyyy
3 days ago
Dejan Lekic
3 days ago
monkyyy
3 days ago
Andy Valencia
3 days ago
monkyyy
3 days ago
Andy Valencia
1 day ago
jmh530
1 day ago
monkyyy
1 day ago
jmh530
September 10

I asked

>

does a preexisting nd array iterator exist?

got links to mir, docs I can barely read (srsly math language is anticomprehension)

ndslice allocates, so, hottake misnamed. A slice is a reference to an array, a dynmaic array is a gc allocated array https://opendlang.org/library/mir.ndslice.allocation.slice.4.html#Slice

Found field, says its a something defined by an opIndex, better, but no nd

fieldnd.dor something exists but it defines 2 types of nd fields and not a generic mapping, idk

FieldIterator exists but its opSlice only takes 2 arguments so I think I can rule it out as nd

etc.

So I dont think it exists in this tangled mess? Maybe, idk? I think in its naming scheme it would be called an ndfield

4 days ago

On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:

>

I asked

>

does a preexisting nd array iterator exist?

got links to mir, docs I can barely read (srsly math language is anticomprehension)

ndslice allocates, so, hottake misnamed. A slice is a reference to an array, a dynmaic array is a gc allocated array https://opendlang.org/library/mir.ndslice.allocation.slice.4.html#Slice

Found field, says its a something defined by an opIndex, better, but no nd

fieldnd.dor something exists but it defines 2 types of nd fields and not a generic mapping, idk

FieldIterator exists but its opSlice only takes 2 arguments so I think I can rule it out as nd

etc.

So I dont think it exists in this tangled mess? Maybe, idk? I think in its naming scheme it would be called an ndfield

Will need to gentricify this, but this seems promising

import std;
struct Tuple(T...){
	enum istuple=true;
	T expand; alias expand this;
}
auto tuple(T...)(T args){
	return Tuple!T(args);
}
unittest{
	auto foo=tuple(1,"hi");
	assert(foo[0]==1);
	assert(foo[1]=="hi");
	auto bar=tuple();
}
enum istuple(T)=is(typeof(T.istuple));
unittest{
	assert(istuple!(typeof(tuple(1,2)))==true);
	assert(istuple!int==false);
}
auto iterate(T,S)(T t,S s){
	struct foreach_{
	int opApply(int delegate(int,int) dg){
		int result;
		static foreach(TI;0..t.length){
		foreach(x;t[TI]){
			static foreach(SI;0..s.length){
			foreach(y;s[SI]){
				result=dg(x,y);
				if(result>2){return result;}
				if(result==1){break;}
			}}
		}}
		return result;
	}}
	return foreach_();
}
unittest{
	loop:foreach(x,y;iterate(tuple(iota(0,3),iota(6,9)),tuple(iota(4,6)))){
		writeln(x,',',y);
		if(x==6){break;}
		if(x==7){break loop;}
}}
3 days ago

On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:

>

I asked

>

does a preexisting nd array iterator exist?

got links to mir, docs I can barely read (srsly math language is anticomprehension)

I can barely read your posts, yet I do not complain...

3 days ago

On Monday, 15 September 2025 at 16:59:58 UTC, Dejan Lekic wrote:

>

On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:

>

I asked

>

does a preexisting nd array iterator exist?

got links to mir, docs I can barely read (srsly math language is anticomprehension)

I can barely read your posts, yet I do not complain...

you havnt? You sure?

3 days ago

On Monday, 15 September 2025 at 17:07:36 UTC, monkyyy wrote:

>

On Monday, 15 September 2025 at 16:59:58 UTC, Dejan Lekic wrote:

>

On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:

>

I asked

>

does a preexisting nd array iterator exist?

got links to mir, docs I can barely read (srsly math language is anticomprehension)

I can barely read your posts, yet I do not complain...

you havnt? You sure?

Not going to lie, I had no idea what "mir" meant, nor what an "nd array" is. For such things I mostly wait and see if I can pick up my answers from the context of any responses.

Mostly! :-)

Andy

3 days ago

On Monday, 15 September 2025 at 20:10:22 UTC, Andy Valencia wrote:

>

On Monday, 15 September 2025 at 17:07:36 UTC, monkyyy wrote:

>

On Monday, 15 September 2025 at 16:59:58 UTC, Dejan Lekic wrote:

>

On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:

>

I asked

>

does a preexisting nd array iterator exist?

got links to mir, docs I can barely read (srsly math language is anticomprehension)

I can barely read your posts, yet I do not complain...

you havnt? You sure?

Not going to lie, I had no idea what "mir" meant, nor what an "nd array" is. For such things I mostly wait and see if I can pick up my answers from the context of any responses.

Mostly! :-)

Andy

mir is a lib that has nd math; that allot of people know is meta programming to hell and back but no one can tell ya how to use it
nd is "N" as anonymous int and D as in dimension, 2d vs 3d vs ... 99d

3 days ago

On Monday, 15 September 2025 at 20:23:23 UTC, monkyyy wrote:

>

mir is a lib that has nd math; that allot of people know is meta programming to hell and back but no one can tell ya how to use it
nd is "N" as anonymous int and D as in dimension, 2d vs 3d vs ... 99d

Cool... thanks. A world I never even knew existed!

Andy

1 day ago

On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:

>

[snip]

Documentation for mir iterators is here:
http://mir-algorithm.libmir.org/mir_ndslice_iterator.html

If you want to use mir without using the GC. You can allocate with malloc, custom allocator, or use an RC allocator.
http://mir-algorithm.libmir.org/mir_ndslice_allocation.html

1 day ago

On Wednesday, 17 September 2025 at 12:06:32 UTC, jmh530 wrote:

>

On Wednesday, 10 September 2025 at 20:23:28 UTC, monkyyy wrote:

>

[snip]

Documentation for mir iterators is here:
http://mir-algorithm.libmir.org/mir_ndslice_iterator.html

I see nd-iota but it seems under powered(handling only the single argument case of iota)
I could spell that auto fixediota(I)(I start,I end)=>iota(end-start).map!(a=>a+start) to get the 2 argument version (3 arguments could be a little tricky)

soooo

fixedndiota(???)=>...
ndfield(???)=>fixediota(???).map!(a=>foo.opIndex(a));

That doesnt seem premade anymore

>

If you want to use mir without using the GC. You can allocate with malloc, custom allocator, or use an RC allocator.
http://mir-algorithm.libmir.org/mir_ndslice_allocation.html

Not about allocating, user defined opIndex on user defined data

If mir only defines a single data-type-family and is deeply opinionated about controlling it(which seems to be increasingly the case) its not generic and leaving some level of simplicity on the table.

1 day ago

On Wednesday, 17 September 2025 at 14:57:19 UTC, monkyyy wrote:

>

[snip]

Sorry, I'm having trouble understanding what you're trying to do.