digitalmars.D.learn - Simultaneously assigning to all values in a tuple
- Jamie (5/5) Mar 27 2019 Is it possible to assign to all values in a tuple at once if they
- Paul Backus (4/11) Mar 30 2019 foreach (ref member; t.expand) {
- Jacob Carlborg (6/13) Apr 01 2019 Yes:
- Simen =?UTF-8?B?S2rDpnLDpXM=?= (5/16) Apr 01 2019 Since the question was how to assign to all values in a tuple:"
- Andrea Fontana (2/18) Apr 01 2019 t.expand = Repeat!(t.length, 1.0);
Is it possible to assign to all values in a tuple at once if they are the same type? I.e. Tuple!(double, "x", double, "y") t; t[] = 1.0;
Mar 27 2019
On 3/27/19 8:29 PM, Jamie wrote:Is it possible to assign to all values in a tuple at once if they are the same type? I.e. Tuple!(double, "x", double, "y") t; t[] = 1.0;foreach (ref member; t.expand) { member = 1.0; }
Mar 30 2019
On 2019-03-28 01:29, Jamie wrote:Is it possible to assign to all values in a tuple at once if they are the same type? I.e. Tuple!(double, "x", double, "y") t; t[] = 1.0;Yes: Tuple!(double, "x", double, "y") t; t.expand = AliasSeq!(3.1, 4.2); -- /Jacob Carlborg
Apr 01 2019
On Monday, 1 April 2019 at 09:46:34 UTC, Jacob Carlborg wrote:On 2019-03-28 01:29, Jamie wrote:Since the question was how to assign to all values in a tuple:" t.expand = Repeat!(2, 1.0); -- SimenIs it possible to assign to all values in a tuple at once if they are the same type? I.e. Tuple!(double, "x", double, "y") t; t[] = 1.0;Yes: Tuple!(double, "x", double, "y") t; t.expand = AliasSeq!(3.1, 4.2);
Apr 01 2019
On Monday, 1 April 2019 at 10:12:50 UTC, Simen Kjærås wrote:On Monday, 1 April 2019 at 09:46:34 UTC, Jacob Carlborg wrote:t.expand = Repeat!(t.length, 1.0);On 2019-03-28 01:29, Jamie wrote:Since the question was how to assign to all values in a tuple:" t.expand = Repeat!(2, 1.0);Is it possible to assign to all values in a tuple at once if they are the same type? I.e. Tuple!(double, "x", double, "y") t; t[] = 1.0;Yes: Tuple!(double, "x", double, "y") t; t.expand = AliasSeq!(3.1, 4.2);
Apr 01 2019