June 12, 2009
> Saaa wrote:
>> I can't figure out how to create the IndexArray function, it should work on arrays of any depth
>
> BaseType!(TArray) index(TArray : TArray[])(TArray array, int[] indices...)
> {
> return index(array[indices[0]], indices[1..$]);
> }
>
> TElement index(TElement)(TElement element, int[] ignored...)
> {
> return element;
> }
>
> This uses template specialization to handle arrays differently than non-arrays (that's what the "TArray : TArray[]" business means). It uses the BaseType template worked out in one of your previous threads. It's close enough to being the simplest thing that could work that I wouldn't bother looking for anything simpler.

I really like templates :D
I actually tried something like this, but I couldn't get it to compile.
My try misses quit a few things I see

void IndexArray(T : T[], U)(T array, U index)
{
  IndexArray( array[index[0]][], index[1..$]);
}

void IndexArray(T : int, U)(T array, U index)
{
  array[index[0]] = -7;//test
}

I did get it to compile at one time, but didn't know how to use it,
like your code..
index( array, index2);  //compiles and all, but how do I set the value?
index( array, index2) = -1; // doesn't work
Also, why the ... ?


June 12, 2009
> I guess it depends on your style.  If you respond to the entire message, then putting at the top makes sense, because then you can read the response quickly, and read the history below if you want.
I also switch my way of reply on the type of the reply and often find it strange people quote the whole post only to reply something general.

>
> But if you want to respond point-by-point, then going below makes sense. You can respond to each point, then have your main point at the bottomm of the message.
Who would do that!

>
> My email clients always put quoted text below.  However, my news client always quotes above.
>
> Someone should do a study...
Don't tell me nobody did that already . .


June 13, 2009
Hello Steven,

> On Fri, 12 Jun 2009 19:40:02 -0400, Denis Koroskin <2korden@gmail.com>
> wrote:
> 
>> Just don't quote. Why include quote, if there is nothing under it?
>> 
> Why is it that some email clients start you out at the top of the
> quoted  messages, and some clients go below?
> 
> I guess it depends on your style.  If you respond to the entire
> message,  then putting at the top makes sense, because then you can
> read the  response quickly, and read the history below if you want.
> 
> But if you want to respond point-by-point, then going below makes
> sense.   You can respond to each point, then have your main point at
> the bottomm of  the message.

I think that bit is the main reason. If you are not referencing something, then delete it from the quote. If you are referencing it, put your stuff below, sort of like a caption.


June 13, 2009
Ever heard of recursion?

Why don't you simply handle all types recursively? Why do you need this "array depth" stuff?
June 13, 2009
> Ever heard of recursion?
>
> Why don't you simply handle all types recursively? Why do you need this "array depth" stuff?

Most probably because I tackle my parsing problem sub-optimally.

This is how I do it:

load file into char[][]
create: int[][][] arr;
call: ddata.get( (in) file, (in) 'array1', (ref) arr);
  find row starting with 'int[][][] array1'.
  parse char by char from there
    every time the end of a value is found convert the slice to the correct
type
    and put it in the corresponding arr index.
return;



June 13, 2009
Saaa wrote:
> I did get it to compile at one time, but didn't know how to use it,
> like your code..
> index( array, index2);  //compiles and all, but how do I set the value?
> index( array, index2) = -1; // doesn't work

If you're using d2, add 'ref' to the return type.

Otherwise, you need indexAssign:

void indexAssign(TArray : TArray[])(TArray array, BaseType!(TArray) value, int[] indices...)
{
	static if (is (typeof (array[0]) == typeof(value))
	{
		array[indices[0]] = value;
	}
	else
	{
		indexAssign(array[indices[0]], value, indices[1..$]);
	}
}

> Also, why the ... ?

In case you know the number of indices ahead of time. It costs nothing and lets you use a more natural syntax some of the time.
June 13, 2009
Saaa wrote:
>> I guess it depends on your style.  If you respond to the entire message,
>> then putting at the top makes sense, because then you can read the response quickly, and read the history below if you want.

If I want to read the whole message you're replying to, I can open up the mesasge you're replying to in my newsreader.

<snip>
>> But if you want to respond point-by-point, then going below makes sense. You can respond to each point, then have your main point at the bottomm of the message.
> Who would do that!

Anybody who is well-educated on how to use newsgroups?

>> My email clients always put quoted text below.  However, my news client always quotes above.
<snip>

Below/above what?

- the cursor?
- one or more blank lines?
- your signature?
- the message you typed, after you hit the send button?

I for one would like to see newsreaders that will, at least as a pref, put the cursor above the quoted text and blank lines/sig below.  This sets the user ready to work down the message, trimming it down and inserting reply text where it fits.  See
https://bugzilla.mozilla.org/show_bug.cgi?id=227376

Stewart.
June 13, 2009
On Sat, 13 Jun 2009 10:51:56 -0400, Stewart Gordon <smjg_1998@yahoo.com> wrote:

> Saaa wrote:
>>> I guess it depends on your style.  If you respond to the entire message,
>>> then putting at the top makes sense, because then you can read the response quickly, and read the history below if you want.
>
> If I want to read the whole message you're replying to, I can open up the mesasge you're replying to in my newsreader.

Yes, but there are some issues there:

1. the newsgroup/newsreader sometimes doesn't correctly put your message as a reply to the original.
2. You may not read messages threaded, so it might be tough to find the original message.
3. You almost ALWAYS want to read the immediately responded-to message for context (i.e. quote level 1), I am annoyed when I have to close the message I was reading to read the one responded to.  Especially when I am following 5 threads at once.

I can see arguments for both methods.  I use both, but only really the second method for newsgroups.  I'm not sure why, but it just feels more natural.

> <snip>
>>> But if you want to respond point-by-point, then going below makes sense. You can respond to each point, then have your main point at the bottomm of the message.
>> Who would do that!
>
> Anybody who is well-educated on how to use newsgroups?

Gee, I don't remember having newsgroups 101 in school :P  In fact, I don't think I ever received education from anyone.  I just do what feels natural, and what makes sense.

>>> My email clients always put quoted text below.  However, my news client always quotes above.
> <snip>
>
> Below/above what?
>
> - the cursor?
Yes

> - one or more blank lines?
Yes

> - your signature?
Yes

> - the message you typed, after you hit the send button?
No, the quoted text appears as I type my message.

> I for one would like to see newsreaders that will, at least as a pref, put the cursor above the quoted text and blank lines/sig below.  This sets the user ready to work down the message, trimming it down and inserting reply text where it fits.  See
> https://bugzilla.mozilla.org/show_bug.cgi?id=227376

That sounds like a feature I would use.  I think another good feature would probably be to limit the quoted text to N levels (do you need 5 levels of context to make your point?).

I do want to say that It doesn't bother me what people do, I just find it interesting how different social tools evolve in different directions, even when the interface is pretty much identical.

-Steve
June 15, 2009
> Ever heard of recursion?
>
> Why don't you simply handle all types recursively?

I'm still very interested in what exactly that means.
Could you maybe give a small example?


June 15, 2009
Hello Saaa,

>> Ever heard of recursion?
>> 
>> Why don't you simply handle all types recursively?
>> 
> I'm still very interested in what exactly that means. Could you maybe
> give a small example?
> 

int Index(T)(T arr, int[] ind)
{
 static if(is(T B == B[][])) // if array of array
     return Index!(B[])(arr[ind[0]], ind[1..$]);
 else
 {
     static assert(is(T B == B[])); // had better be an array;
     return arr[ind[0]];
 }
}

void main()
{
   int[][][] d;
   d.length = 3;
   d[1].length = 3;
   d[1][2].length = 3;
   d[1][2] = [0,1,1];

   assert(0==Index!(int[][][])(d,[1,2,0]));
}