Re: Hopefully a simple question...

2017-01-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 13 January 2017 at 16:56:43 UTC, WhatMeWorry wrote: I'm converting some C++ and glm code to D and gl3n. And I'm stumped at the following line. GLboolean CheckCollision(BallObject , GameObject ) // AABB - Circle collision { // Get center point circle first glm::vec2

Re: switch to member

2017-01-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 14 January 2017 at 03:20:24 UTC, Ignacious wrote: When doing common functionality for a switch, is there any way to optimize: switch(x) { case X: q.X = e; break; case Y: q.Y = e; break etc... } e is basically a value that, depending

switch to member

2017-01-13 Thread Ignacious via Digitalmars-d-learn
When doing common functionality for a switch, is there any way to optimize: switch(x) { case X: q.X = e; break; case Y: q.Y = e; break etc... } e is basically a value that, depending on the what kind(x), we assign it to a field in q. The name of

Re: Converting from DirIterator to string[] without a loop

2017-01-13 Thread Ali Çehreli via Digitalmars-d-learn
On 01/13/2017 04:29 PM, Dave Chapman wrote: > When I use auto and print out the type of b it is something like > args.main.FilterResult!(__lambda2, DirIterator).FilterResult and for the > "if" version of > b and args.main.FilterResult!(__lambda3, DirIterator).FilterResult for > the "else"

Converting from DirIterator to string[] without a loop

2017-01-13 Thread Dave Chapman via Digitalmars-d-learn
I would like to do something like the code shown below but I can't figure out how to do it without loops inside the if statement. When I use auto and print out the type of b it is something like args.main.FilterResult!(__lambda2, DirIterator).FilterResult and for the "if" version of b and

Re: Merging two arrays in a uniform order

2017-01-13 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 13 January 2017 at 19:47:38 UTC, aberba wrote: awesome. roundRobin? :) https://dlang.org/phobos/std_range.html#.roundRobin [quote] roundRobin(r1, r2, r3) yields r1.front, then r2.front, then r3.front, after which it pops off one element from each and continues again from r1. For

Re: Merging two arrays in a uniform order

2017-01-13 Thread aberba via Digitalmars-d-learn
On Friday, 13 January 2017 at 12:00:41 UTC, ZombineDev wrote: On Friday, 13 January 2017 at 06:32:02 UTC, aberba wrote: Unlike array1 + array2, how can i merge arrays such that: [a1, a1, a2, a1, a1, a2, a1] //uniform order where a1 = child of array1, a2 = child of array2 using a built-in

Re: Hopefully a simple question...

2017-01-13 Thread kinke via Digitalmars-d-learn
On Friday, 13 January 2017 at 16:56:43 UTC, WhatMeWorry wrote: A vec and scalar can't be added together. So why (or how) is the glm code working? The C++ source disagrees: https://github.com/g-truc/glm/blob/master/glm/detail/type_vec2.hpp#L219 It works via operator overloading, and adding a

Re: Merging two arrays in a uniform order

2017-01-13 Thread ZombineDev via Digitalmars-d-learn
On Friday, 13 January 2017 at 06:32:02 UTC, aberba wrote: Unlike array1 + array2, how can i merge arrays such that: [a1, a1, a2, a1, a1, a2, a1] //uniform order where a1 = child of array1, a2 = child of array2 using a built-in function/algorithm (is/are there anything(s) in Phobos for