Re: Input/Output multiple values from function

2019-09-02 Thread Ali Çehreli via Digitalmars-d-learn
On 08/27/2019 10:17 PM, Jabari Zakiya wrote: > I can't do (a, b, c,d) = func1(i) directly. > What do I do to assign the output of func1 to the individual variables? I had some time to play with the following syntax, similar usage of which has been proposed a number of times as a replacement

Re: Input/Output multiple values from function

2019-09-02 Thread Jabari Zakiya via Digitalmars-d-learn
On Sunday, 1 September 2019 at 20:50:42 UTC, Paul Backus wrote: On Sunday, 1 September 2019 at 20:42:28 UTC, Jabari Zakiya wrote: It still won't compile, with this error. Error: AliasSeq!(modpg, res_0, restwins, resinvrs) is not an lvalue and cannot be modified Here's a gist of the code.

Re: Input/Output multiple values from function

2019-09-01 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 1 September 2019 at 20:42:28 UTC, Jabari Zakiya wrote: It still won't compile, with this error. Error: AliasSeq!(modpg, res_0, restwins, resinvrs) is not an lvalue and cannot be modified Here's a gist of the code. Top functions in code with issues are genPgParameters and

Re: Input/Output multiple values from function

2019-09-01 Thread Jabari Zakiya via Digitalmars-d-learn
On Thursday, 29 August 2019 at 10:58:47 UTC, Simen Kjærås wrote: On Thursday, 29 August 2019 at 10:39:44 UTC, Jabari Zakiya wrote: [...] Great - then you can use shared(immutable(uint)[]). You should be able to convert from immutable(uint[]) to that without issue. There's a utility function

Re: Input/Output multiple values from function

2019-08-29 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 29 August 2019 at 10:39:44 UTC, Jabari Zakiya wrote: The values modpg, res_0, restwins, and resinvrs are constant (immutable) values that are generated at run time. They are global/shared and used inside threads. So this process is initializing them at the start of the program,

Re: Input/Output multiple values from function

2019-08-29 Thread Jabari Zakiya via Digitalmars-d-learn
On Thursday, 29 August 2019 at 09:04:17 UTC, Simen Kjærås wrote: On Wednesday, 28 August 2019 at 13:11:46 UTC, Jabari Zakiya wrote: [...] Reduced example: unittest { int[] a; // cannot implicitly convert expression a of type int[] to shared(int[]) shared int[] b = a; } This is

Re: Input/Output multiple values from function

2019-08-29 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 13:11:46 UTC, Jabari Zakiya wrote: When I do this: uint a; uint b; uint[] c; uint[] d; AliasSeq!(a, b, c, d) = genPGparameters(pg); modpg= a; res_0= b; restwins = c; resinvrs = d; the compiler (ldc2 1.17) says: D Projects ~/D/bin/ldc2

Re: Input/Output multiple values from function

2019-08-28 Thread Jabari Zakiya via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 10:10:08 UTC, Simen Kjærås wrote: On Wednesday, 28 August 2019 at 05:17:28 UTC, Jabari Zakiya wrote: Inside func2 I create an input value for func1 and then assign func1's 4 outputs to named variable. That's where the problems arise. func1 does some math based

Re: Input/Output multiple values from function

2019-08-28 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 05:17:28 UTC, Jabari Zakiya wrote: Inside func2 I create an input value for func1 and then assign func1's 4 outputs to named variable. That's where the problems arise. func1 does some math based on the input and generates 4 outputs. I can't do (a, b, c,d) =

Re: Input/Output multiple values from function

2019-08-28 Thread a11e99z via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 05:17:28 UTC, Jabari Zakiya wrote: On Wednesday, 28 August 2019 at 04:39:23 UTC, Mike Parker wrote: On Wednesday, 28 August 2019 at 04:19:49 UTC, Jabari Zakiya wrote: I have a function (say func1) that takes 1 input value (an integer number) and outputs 4 values

Re: Input/Output multiple values from function

2019-08-27 Thread Jabari Zakiya via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 04:39:23 UTC, Mike Parker wrote: On Wednesday, 28 August 2019 at 04:19:49 UTC, Jabari Zakiya wrote: I have a function (say func1) that takes 1 input value (an integer number) and outputs 4 values (2 integers and 2 arrays of integers). Then inside another

Re: Input/Output multiple values from function

2019-08-27 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 04:19:49 UTC, Jabari Zakiya wrote: I have a function (say func1) that takes 1 input value (an integer number) and outputs 4 values (2 integers and 2 arrays of integers). Then inside another function (say func2) I provide the 1 input to func1 and then want to

Input/Output multiple values from function

2019-08-27 Thread Jabari Zakiya via Digitalmars-d-learn
I have a function (say func1) that takes 1 input value (an integer number) and outputs 4 values (2 integers and 2 arrays of integers). Then inside another function (say func2) I provide the 1 input to func1 and then want to assign its 4 output values to their appropriate final variables that