Is this code correct?

2023-03-30 Thread z via Digitalmars-d-learn
Is this code correct or logically sound? ```D import std; enum {side/depth/height and side/height x,//0 y,//1 z //2 } /** Indicates wether a triangle faces an imaginary view point. */ bool triangleFacesCamera(float[3] tA, float[3] tB, float[3] tC) { float r1, r2; r1 = atan2(tB[x] - tA[x], tB

Re: Is this code correct?

2023-03-30 Thread Dennis via Digitalmars-d-learn
On Thursday, 30 March 2023 at 10:29:25 UTC, z wrote: Is this code correct or logically sound? You need to be exact on what 'correct' is. The comment above `triangleFacesCamera` says: Indicates wether a triangle faces an imaginary view point. There's no view point / camera position defined

Re: The Phobos Put

2023-03-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/29/23 11:01 PM, Salih Dincer wrote: ```d import std.algorithm.mutation : copy; void main() {   int[8] buf;   auto dig = [1, 2, 3, 4];   auto rem = dig.copy(buf);   assert(rem.length == 4); } ``` Looks like 'copy' has the same overload issue. A static array is not a range of any kind

Re: The Phobos Put

2023-03-30 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 29 March 2023 at 20:50:04 UTC, Steven Schveighoffer wrote: On 3/29/23 4:29 PM, ag0aep6g wrote: But regardless of Salih's exact intent, the broader point is: a non-ref overload could be added to Phobos. And that would enable `a[1..$-1].phobos_put([2, 3])`. Which is what he asked

Re: The Phobos Put

2023-03-30 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 30 March 2023 at 13:27:33 UTC, Steven Schveighoffer wrote: But you can do `dig.copy(buf[])` since a dynamic array is. Apparently, we will not be able to get rid of the necessity of using slices. 😀 Neither with "copy" nor with "put"... ```d import std.algorithm.mutation : copy;

Re: Step by step tutorials for using bindings in D

2023-03-30 Thread Inkrementator via Digitalmars-d-learn
On Monday, 27 March 2023 at 00:45:28 UTC, Salih Dincer wrote: Likes **17** Views **265** Released on March **8, 2023** I'm surprised that you can get 300 views in a month on a primarily D video, but it's nice to see

Re: The Phobos Put

2023-03-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/30/23 11:44 AM, Paul Backus wrote: It should be fine to have both a `ref` and non-`ref` overload for `put`, though, right? If the non-`ref` overload is only called with rvalues, then it's fine to leave them in an undetermined state, because nothing can access them afterward anyway. Ther

InputRange in arrays

2023-03-30 Thread Salih Dincer via Digitalmars-d-learn
Hi, there is a feature when working with the InputRange. I don't know when it released available. May be somewhere D compiler between v2.087 and v2.096 (works) but definitely not before v2.087 (including)... Anyone know this? ```d import std.range.primitives; void main() { auto arr = [0, 1]

Re: InputRange in arrays

2023-03-30 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 31 March 2023 at 03:39:51 UTC, Salih Dincer wrote: May be somewhere D compiler between v2.087 and v2.096 (works) but definitely not before v2.087 (including)... Edit: The Phobos library I'm using is corrupted. That's why the last line was giving an error. But has it always been poss

Re: InputRange in arrays

2023-03-30 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 31 March 2023 at 04:15:24 UTC, Salih Dincer wrote: ...has it always been possible for arrays to be used as if they were ranges? Playground is a very useful tool, it responds right away :) Up to 2.078.3: Failure with output: - onlineapp.d(4): Error: no property 'popFront'