On Thu, Aug 14, 2014 at 17:01, Peter Bortas wrote:

>You brought it up, so however you define it is the correct definition.

Thanks. :)

I can now inform you about other good news: Automap is more complex!

Now and then it now works to have an automap as the left side of an
assignment.

So, what does that mean, one wonders?

Normal ye olde automap:

| > array a = allocate(2);
| > a[*] += 20;
| > a[*] = a[*]+10;
| > a[*] = 20+a[*];
| Result: ({ 50, 50 })

Well, that was expected, right? Before my changes the first version
was the only one that worked, but they are not doing anything
unexpected.

However, how about this nugget of readability:

| > a[*] = Array.shuffle(allocate(1)+(a[*]+20)));
| Result: ({ ({ 70, 0, 70 }),
|            ({ 70, 0, 70 }) })


What happened there? The left side is an automap, the right side is
sort of not. So, instead this evaluates to something along the lines
of

| array b= Array.shuffle(allocate(1)+(a[*]+20)));
| a[*] = b;

Which might not be all that useful, but who knows? This is,
incidentally, also a new feature. Setting all the elements in an array
to one value, that is.

On a somewhat realted note

| a[*] = 0;

is actually faster than

| a = allocate(sizeof(a));

or one of the for-loop based alternatives. :)


But wait, there is more!

| > a[*][*] = "hej";
|
| Result: ({ ({ "hej", "hej", "hej"  }),
|            ({ "hej", "hej", "hej"  }) })

And of course:

| > a[1] = copy_value(a[1]);
| > a[1][*] = "world";
| Result: ({ ({ "hej", "hej", "hej"  }),
|            ({ "world", "world", "world"  }) })

However, it still does not work to reverse the indexes:

| a[*][0] = "hello";

which, logically, should produde this:

| Result: ({ ({ "hello", "hej", "hej"  }),
|            ({ "hello", "world", "world"  }) })

No such luck yet, however. This is nothing new, though.

-- 
Per Hedbor

Reply via email to