Re: Ali's Book - Programming in D

2021-09-11 Thread Ron Tarrant via Digitalmars-d-learn
On Friday, 10 September 2021 at 22:26:34 UTC, Ali Çehreli wrote: Not off the top of my head but by actual commits. :) https://bitbucket.org/acehreli/ddili/commits/ One major change that I can see is @property being discouraged. Good to know. Thanks, Ali.

Proper way to accept either static or dynamic array as a parameter

2021-09-11 Thread Alex Bryan via Digitalmars-d-learn
I am having trouble discovering what the proper (or at least a proper) way is to write a function that can take either a static or dynamic array as a parameter. My current implementation consists of 2 overloaded functions (one takes a dynamic array, the other takes a static array) with 99%

Re: Proper way to accept either static or dynamic array as a parameter

2021-09-11 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Sep 12, 2021 at 01:08:17AM +, Alex Bryan via Digitalmars-d-learn wrote: > I am having trouble discovering what the proper (or at least a proper) > way is to write a function that can take either a static or dynamic > array as a parameter. My current implementation consists of 2 >

Re: Proper way to accept either static or dynamic array as a parameter

2021-09-11 Thread Alex Bryan via Digitalmars-d-learn
On Sunday, 12 September 2021 at 01:48:07 UTC, H. S. Teoh wrote: On Sun, Sep 12, 2021 at 01:08:17AM +, Alex Bryan via Digitalmars-d-learn wrote: I am having trouble discovering what the proper (or at least a proper) way is to write a function that can take either a static or dynamic array

Re: Proper way to accept either static or dynamic array as a parameter

2021-09-11 Thread jfondren via Digitalmars-d-learn
On Sunday, 12 September 2021 at 02:44:36 UTC, Alex Bryan wrote: `T[] dynArr` can be passed (by reference) to a function that takes `ref T[] data` but `T[10] data` cannot? Why not? ```d void add1(ref int[] nums) { nums ~= 1; } unittest { int[] nums; nums.add1; nums.add1;

Re: Array permutations

2021-09-11 Thread Vino via Digitalmars-d-learn
On Saturday, 11 September 2021 at 19:57:26 UTC, jfondren wrote: On Saturday, 11 September 2021 at 19:37:42 UTC, Vino wrote: Hi All, Request your help on the below to print the below array as "Required output", Was able to get these values "[1,2],[2,3],[3,4],[4,5]" by using list.slide(2),

Re: Array permutations

2021-09-11 Thread Vino via Digitalmars-d-learn
On Saturday, 11 September 2021 at 23:04:29 UTC, Vino wrote: On Saturday, 11 September 2021 at 19:57:26 UTC, jfondren wrote: [...] Hi, Thank you very much, let me try to explain the actual requirement, the actual requirement is to find all the permutations of a given array, I modified

File difference module similar to the Linux command "comm"

2021-09-11 Thread Vino via Digitalmars-d-learn
Hi All, May i know whether there is any module similar to the Linux command "comm" (finding difference between 2 files), if present can you please guide me through link to the page nor do let me know if there is any other solution. Eg File1 list1 list2 list3 lsit5 File2 list1 list3

Re: File difference module similar to the Linux command "comm"

2021-09-11 Thread jfondren via Digitalmars-d-learn
On Saturday, 11 September 2021 at 23:17:31 UTC, Vino wrote: Hi All, May i know whether there is any module similar to the Linux command "comm" (finding difference between 2 files), if present can you please guide me through link to the page nor do let me know if there is any other

Re: Array permutations

2021-09-11 Thread jfondren via Digitalmars-d-learn
On Saturday, 11 September 2021 at 19:37:42 UTC, Vino wrote: Hi All, Request your help on the below to print the below array as "Required output", Was able to get these values "[1,2],[2,3],[3,4],[4,5]" by using list.slide(2), need your help to get values

Re: Array permutations

2021-09-11 Thread Dukc via Digitalmars-d-learn
On Saturday, 11 September 2021 at 19:37:42 UTC, Vino wrote: Request your help on the below to print the below array as "Required output", Was able to get these values "[1,2],[2,3],[3,4],[4,5]" by using list.slide(2), need your help to get values "1,3],[1,4],[1,5],[2,4],[2,5],[3,5]" ```d

Re: Array permutations

2021-09-11 Thread jfondren via Digitalmars-d-learn
On Saturday, 11 September 2021 at 19:57:26 UTC, jfondren wrote: auto pairs = list.cartesianProduct(list.drop(1)) This `drop` isn't necessary.

Re: Ali's Book - Programming in D

2021-09-11 Thread Dukc via Digitalmars-d-learn
On Friday, 10 September 2021 at 22:26:34 UTC, Ali Çehreli wrote: https://bitbucket.org/acehreli/ddili/commits/ Ah it's there - gotta remember that place if I want to make corrections. Good book - It's the one that got me up to speed with D before I was commited enough to pay for anything.

Array permutations

2021-09-11 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on the below to print the below array as "Required output", Was able to get these values "[1,2],[2,3],[3,4],[4,5]" by using list.slide(2), need your help to get values "1,3],[1,4],[1,5],[2,4],[2,5],[3,5]" auto list[] = [1,2,3,4,5] Required output