How to Humanize Numerical Input|Output

2024-09-09 Thread Jabari Zakiya via Digitalmars-d-learn
I have this code to input integer values: ``` ulong[] x; foreach (_; 0 .. 2) { ulong a; readf!" %d"(a); x ~= a; } end_num = max(x[0], 3); start_num = max(x[1], 3); if (start_num > end_num) swap(start_num, end_num); start_num = start_num | 1; // if start_num even add 1 e

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

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 functi

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 on

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-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-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. To

Re: help with prime pairs code

2025-02-04 Thread Jabari Zakiya via Digitalmars-d-learn
On Monday, 3 February 2025 at 04:59:43 UTC, monkyyy wrote: On Monday, 3 February 2025 at 04:15:09 UTC, Jabari Zakiya wrote: I translated this Ruby code: FYI. This code finds all the prime pairs that sum to n for all even integers n > 2. It (Ruby code) is included in a paper I just released

Re: help with prime pairs code

2025-02-08 Thread Jabari Zakiya via Digitalmars-d-learn
On Wednesday, 5 February 2025 at 21:24:51 UTC, Jabari Zakiya wrote: On Tuesday, 4 February 2025 at 17:17:42 UTC, Jabari Zakiya wrote: On Monday, 3 February 2025 at 04:59:43 UTC, monkyyy wrote: On Monday, 3 February 2025 at 04:15:09 UTC, Jabari Zakiya wrote: I translated this Ruby code: FY

Re: help with prime pairs code

2025-02-05 Thread Jabari Zakiya via Digitalmars-d-learn
On Tuesday, 4 February 2025 at 17:17:42 UTC, Jabari Zakiya wrote: On Monday, 3 February 2025 at 04:59:43 UTC, monkyyy wrote: On Monday, 3 February 2025 at 04:15:09 UTC, Jabari Zakiya wrote: I translated this Ruby code: FYI. This code finds all the prime pairs that sum to n for all even in

Re: help with prime pairs code

2025-02-01 Thread Jabari Zakiya via Digitalmars-d-learn
On Saturday, 1 February 2025 at 00:21:22 UTC, user1234 wrote: On Friday, 31 January 2025 at 20:05:54 UTC, Jabari Zakiya wrote: [...] A first draft of the translation, not very idiomatic D code: ```d module prime_pairs; import std; [...] Thank you very much! As you can see, D is not my pri

Re: help with prime pairs code

2025-02-01 Thread Jabari Zakiya via Digitalmars-d-learn
On Sunday, 2 February 2025 at 01:39:34 UTC, user1234 wrote: On Sunday, 2 February 2025 at 01:12:59 UTC, user1234 wrote: On Saturday, 1 February 2025 at 21:56:23 UTC, Jabari Zakiya wrote: On Saturday, 1 February 2025 at 00:21:22 UTC, user1234 wrote: On Friday, 31 January 2025 at 20:05:54 UTC, Ja

help with prime pairs code

2025-01-31 Thread Jabari Zakiya via Digitalmars-d-learn
I'm converting Ruby code to D and am running into issues. Would appreciate what needs to be done to get it to compile/run correctly. Here's the Ruby code: ``` # Enable YJIT if using CRuby >= 3.3" RubyVM::YJIT.enable if RUBY_ENGINE == "ruby" and RUBY_VERSION.to_f >= 3.3 def prime_pairs_lohi(

Re: help with prime pairs code

2025-02-18 Thread Jabari Zakiya via Digitalmars-d-learn
// convert lhr_mults vals > n/2 to their lhr complements n-r, // store them, those < n/2, in lhr_del; it now holds non-pcp lhr vals auto lhr_del = lhr_mults.map!((r_del) => r_del > ndiv2 ? n - r_del : r_del).array; lhr_del.sort!("a < b"); lhr = setDifference(lhr, l