Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30755
| From | "Chris M. Thomasson" <invalid@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Impact of implicit arrays... |
| Date | 2016-06-25 18:03 -0700 |
| Organization | n/a |
| Message-ID | <nkn9kd$kfc$1@dont-email.me> (permalink) |
| References | (5 earlier) <99986aa5-dd0c-45a1-a294-90d9c5cada54@googlegroups.com> <nkd300$iml$1@dont-email.me> <994a5f96-b90f-4078-8626-543bf6a2e9e6@googlegroups.com> <nkhkt6$dfv$1@dont-email.me> <bc601b80-611c-4775-9343-f425f0de0326@googlegroups.com> |
On 6/24/2016 7:16 AM, Michael Haufe (TNO) wrote:
> On Thursday, June 23, 2016 at 4:38:51 PM UTC-5, Chris M. Thomasson wrote:
>> On 6/21/2016 11:09 PM, Michael Haufe (TNO) wrote:
>>> On Tuesday, June 21, 2016 at 11:08:39 PM UTC-5, Chris M. Thomasson wrote:
>> [...]
>>> even in your example the roots array still only has two components per entry
>>
>> Yup. Humm, how about the following functional addition function:
>>
>> (please excuse any typos, I typed this in the newsreader)
>> _______________________________________
>> function ct_complex_add(a, b) {
>> var n = Math.min(a.length, b.length);
>>
>> var sum = new Array(n);
>>
>> for (var i = 0; i < n; ++i) {
>> sum[i] = a[i] + b[i];
>> }
>>
>> return sum;
>> }
>> _______________________________________
>>
>>
>> You can call it like:
>> _______________________________________
>> {
>> var r = ct_complex_add([1, 2], [3, 4]);
>> alert("r:(" + r + ")");
>> return true;
>> }
>> _______________________________________
>>
>>
>> We can add extra elements to the arrays, and the function
>> (ct_complex_add) still works:
>>
>> _______________________________________
>> {
>>
>> var r = ct_complex_add([1, 2, 3, 4], [5, 6, 7, 8]);
>> alert("r:(" + r + ")");
>> return true;
>> }
>> _______________________________________
>>
>>
>>
>>
>> We can add extra elements or even pass arrays that have different number
>> of elements:
>> _______________________________________
>> {
>>
>> var r = ct_complex_add([1, 2, 3], [4, 5, 6, 7]);
>> alert("r:(" + r + ")");
>> return true;
>> }
>> _______________________________________
>>
>>
>>
>> What do you think of this? Is it a bit too contrived?
>
> What do the arrays represent in this case? Before it was [Re,Im]
>
x, y, z, w? I admit this is highly contrived wrt justifying arrays via
looping... ;^o
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.com> - 2016-06-11 10:52 -0700
Re: Impact of implicit arrays... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-12 12:16 +0200
Re: Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.com> - 2016-06-13 12:23 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-13 22:00 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.com> - 2016-06-14 17:17 -0700
Re: Impact of implicit arrays... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-15 06:55 +0200
Re: Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.invalid> - 2016-06-14 22:19 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-18 12:47 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 14:43 -0700
Re: Impact of implicit arrays... "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-22 00:10 +0200
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 15:28 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 15:31 -0700
Re: Impact of implicit arrays... "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-22 11:55 +0200
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 12:23 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 14:14 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 14:16 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 18:14 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 18:46 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-21 17:35 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 21:08 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-21 23:09 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 14:38 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-24 07:16 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-25 18:03 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-25 18:24 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-07-01 13:52 -0700
csiph-web