Re: how to build DSFMLC ?

2018-08-24 Thread Flaze07 via Digitalmars-d-learn

On Sunday, 19 August 2018 at 08:57:05 UTC, Flaze07 wrote:

I keep having the same problem with building DSFMLC

https://ibb.co/edRStK


for anyone having the same problem, I found the solution in 
another thread. You have to use MinGW32 bit version if you use 
mingw, as for visual C++, I think you can use both 32 bit and 64 
bit


how to build DSFMLC ?

2018-08-19 Thread Flaze07 via Digitalmars-d-learn

I keep having the same problem with building DSFMLC

https://ibb.co/edRStK


Re: how to compile D programs without console window

2018-07-14 Thread Flaze07 via Digitalmars-d-learn

On Sunday, 15 July 2018 at 01:20:25 UTC, evilrat wrote:

...
"lflags": [ "/SUBSYSTEM:windows" ],
...


didn't know that, thank you




Re: how to compile D programs without console window

2018-07-14 Thread Flaze07 via Digitalmars-d-learn

On Saturday, 14 July 2018 at 09:39:21 UTC, rikki cattermole wrote:

If you're using dub, throw them into lflags and remove the -L.

https://forum.dlang.org/post/gmcsxgfsfnwllploo...@forum.dlang.org
hmm, for some unknown reason it says that it is unable to find 
SUBSYSTEM:windows.lib






how to compile D programs without console window

2018-07-14 Thread Flaze07 via Digitalmars-d-learn
how do you compile a D programs without a console window ? I 
found this link
https://wiki.dlang.org/D_for_Win32 I know that you need .def 
file, but how do you link to .def ?


Re: class that is initialized becomes null when outside of function

2018-07-09 Thread Flaze07 via Digitalmars-d-learn

On Monday, 9 July 2018 at 09:38:30 UTC, ag0aep6g wrote:
The `win` you're creating in `init` is a function-local 
variable. It ceases to exist when `init` returns. It's not 
`this.win`.


In `run`, you're accessing `this.win`. It's still null because 
you never assigned anything there.


So change `auto win = ...;` to `this.win = ...;` or simply `win 
= ...;`.


oops, I forgot... haha what a silly mistake, thank you


Re: class that is initialized becomes null when outside of function

2018-07-09 Thread Flaze07 via Digitalmars-d-learn

On Monday, 9 July 2018 at 09:18:50 UTC, Flaze07 wrote:

I am using DSFML
module game;

[...]


oh, and I forgot, I had

Game myGame;
static this()
{
myGame = new Game;
}

below the Game class


class that is initialized becomes null when outside of function

2018-07-09 Thread Flaze07 via Digitalmars-d-learn

I am using DSFML
module game;

import core.time;

import std.stdio: writeln;

import dsfml.graphics;

import dsfgui.button;

import apple;
import snake;

class Game
{
private:
enum State { menu, playing }
State state;
Font font;
Button playBtn;
Snake snake;
Apple apple;
RenderWindow win;
int size;
protected:
this(){}
public:
void init()
{
import std.exception : enforce;

size = 10;

auto win = new RenderWindow( VideoMode( 600, 600 ), 
"snake" );


font = new Font;
enforce( font.loadFromFile( "media/arial.ttf" ), "failed 
to load font arial" );


playBtn = new Button( "play", font );
playBtn.position = Vector2f( 300, 300 );

snake = new Snake( size, 3, Vector2f( win.size.x, 
win.size.y ) );
apple = new Apple( size / 2, Vector2f( win.size.x, 
win.size.y ) );

}
void run()
{
auto clock = new Clock;
writeln( win is null );
while( win.isOpen() )
{
writeln("lol" );
}
}
}

the problem here is, during init(), the writeln will output 
false, which means yes win is initialized, however during run(), 
suddenly win is null becomes true...


and here is my main()
void main( string[] args )
{
myGame.init();
myGame.run();
}

P.S I tested this with int* and it don't become null when 
function ends


Re: how to do template constraints with variadic templates ?

2018-07-07 Thread Flaze07 via Digitalmars-d-learn

On Sunday, 8 July 2018 at 02:10:12 UTC, Simen Kjærås wrote:
Also, you should probably use CommonType!A for the type of 
temp, since an int can't hold all the possible values of a long 
or ulong (or even uint), and you'll thus get unexpected results 
with large numbers.


--
  Simen
I see, thanks, it's helpful. I really should check out std.meta 
alot more




Re: how to do template constraints with variadic templates ?

2018-07-07 Thread Flaze07 via Digitalmars-d-learn

On Sunday, 8 July 2018 at 00:46:13 UTC, Flaze07 wrote:
I want to force the variadic templates's type to be of certain 
types, I thought doing this would work

auto sum( A... )( A a ) if( isIntegral!( typeid( a[ 0 ] ) ) )
{
int temp;
foreach( t ; a )
{
temp += t;
}
return temp;
}
but it gives out error
( note : I want all the parameter to be integral, i.e sum( 1, 
2, 5, "error" ); //error


I uhh managed to do it with this code
auto sum( A... )( A a )
{
static foreach( t ; a )
{
static assert( isIntegral!( typeof( t ) ) );
}
int temp;
foreach( t ; a )
{
temp += t;
}
return temp;
}
but, I just want to ask something, is the static assert still 
runned during runtime ?


how to do template constraints with variadic templates ?

2018-07-07 Thread Flaze07 via Digitalmars-d-learn
I want to force the variadic templates's type to be of certain 
types, I thought doing this would work

auto sum( A... )( A a ) if( isIntegral!( typeid( a[ 0 ] ) ) )
{
int temp;
foreach( t ; a )
{
temp += t;
}
return temp;
}
but it gives out error
( note : I want all the parameter to be integral, i.e sum( 1, 2, 
5, "error" ); //error


Re: Outside array bounds

2018-07-07 Thread Flaze07 via Digitalmars-d-learn

On Saturday, 7 July 2018 at 08:09:51 UTC, vino.B wrote:

Hi All,

  Request you help, on the below code

import std.stdio: writeln;

void process(T ...)(string ID, T args) {
if (ID == "I1") { writeln(args.length, "\t", args[0]); }
else if (ID == "I2") { writeln(args.length, "\t", args[1]);}
}

void main() {
string S1 = "Test1", S2 = "Test2", ID1 = "I1", ID2 = "I2";
int Size = 1;
process(ID1, S1);
process(ID2, S2, Size);
}

Error:
Test.d(5): Error: array index [1] is outside array bounds [0 .. 
1]
Test.d(11): Error: template instance `Test.process!string` 
error instantiating


From,
Vino.B


in the first process template instantiation, you have a code that 
has args[ 1 ], despite the size being 1, which means you can only 
have args[ 0 ], how about changing the code to instead args[ $ - 
1 ] ?


Re: how to link self made lib using dub

2018-07-06 Thread Flaze07 via Digitalmars-d-learn

On Friday, 6 July 2018 at 21:13:37 UTC, Timoses wrote:

Shouldn't this be 'import output'?
nah, because I didn't import source directly, I import experiment 
so in order to use it, I do source/output.d, which when importing 
module means, source.output
and this '...\\experiment\\source\\'? (I'm not accustomed to 
Windows..)


nope, because I want to do make some sort of a package thing


You could also add a dependency to your other dub project and 
dub should automatically add the import and linker flags.

Add this to your dub.json:

"dependencies":
{
"experiment": {"version": "*", "path": "../experiment"}
}

I didn't test this now, but it should work something like that 
(again, not sure about Windows path...).


See also: 
http://code.dlang.org/package-format?lang=json#version-specs


huh, didn't know I could do that


how to link self made lib using dub

2018-07-06 Thread Flaze07 via Digitalmars-d-learn
I have been trying to link self made .lib, and have tried to use 
it several times, I failed..
so, here I have a file in this path : 
Z:\programming\D\usefulFiles\experiment\source\output.d


it has

module output;

class Output {
public:
static void write( string msg ) {
import std.stdio;
writeln( msg );
}
}

and then I compiled it into library using dub project with this 
file in a path : Z:\programming\D\usefulFiles\experiment\dub.json


{
  "name" : "experiment",
  "targetType": "library",
  "targetPath": "lib",
  "sourcePaths": [
"source",
  ],
}

then, I made a project, with this main in this path : 
Z:\programming\D\experimentLib\source\main.d


it contains this

module main;

import std.stdio;

import source.output;

void main( string[] args ) {
Output.write( "lol" );
readln();
}

and then, I have a dub file in this path : 
Z:\programming\D\experimentLib\dub.json


it contains :

{
  "name" : "experimentlib",
  "targetType": "executable",
  "targetPath": "bin",
  "importPaths": [
"Z:\\programming\\D\\usefulFiles\\experiment\\",
  ],
  "lflags": [
"+Z:\\programming\\D\\usefulFiles\\experiment\\lib\\",
  ],
}

so, I have made lflags to include the lib in experiment, but 
still, it failed to linker ( it compiles fine, but the linker 
fails )





Re: how to import file from another path in dub ?

2018-07-05 Thread Flaze07 via Digitalmars-d-learn

On Thursday, 5 July 2018 at 08:55:13 UTC, Timoses wrote:

Depending on your use case I see these options:
- If you have a library that defines the symbols that you are 
using in the imported files you could use the dub `libs` setting
- Otherwise, if you're just using the other folder to separate 
code you can redefine dub's `sourcePaths`. I believe it 
overwrites the previous, so you have to include your 'source' 
folder again:


"sourcePaths": ["source", ""]


When using sourcePaths, dub actually passes all files within 
all mentioned paths to dmd to compile.



Hope I got it right : D.


I see...so that means, I only need importPaths if I have compiled 
it to libs got it


Re: Cleanup class after method?

2018-07-04 Thread Flaze07 via Digitalmars-d-learn

On Wednesday, 4 July 2018 at 16:02:25 UTC, Jonathan M Davis wrote:
-dip1000 fully implements scope so that it verifies that no 
reference escapes, but it's not ready yet, let alone the 
default behavior.


- Jonathan M Davis


I read the proposal about -dip1000 ( not all, some ) and there is 
also a scoped! template in std.typecons, so...is it better to use 
the scope keyword, or scoped! template


how to import file from another path in dub ?

2018-07-04 Thread Flaze07 via Digitalmars-d-learn
I have a dub project, and I put the importPath to the path of the 
file I want to import and the source file to the source folder, 
and it appears that I have succeeded at importing the module, but 
there's one problem, it appears like I need to define some sort 
of thing, because the error says " Error 42: Symbol Undefined 
__D9animation12__ModuleInfoZ" ( I am using coedit ), do I need to 
compile the file into .lib ?


Re: how to create an array of scoped objects ?

2018-07-03 Thread Flaze07 via Digitalmars-d-learn

On Tuesday, 3 July 2018 at 15:06:28 UTC, Mike Parker wrote:

..
That said, the GC in D runs when main exits anyway, so the 
destructor in your example will be called. That's why I warned 
earlier about it being nondeterministic. For example, if you 
have a Texture instance that depends on the context of the 
RenderWindow, but the RenderWindow's destructor runs first, you 
could potentially see a crash on exit depending on the 
implementation of DSFML, SFML, and the system graphics driver.


I see, so that's what you meant, thank you


Re: how to create an array of scoped objects ?

2018-07-03 Thread Flaze07 via Digitalmars-d-learn

On Tuesday, 3 July 2018 at 14:32:01 UTC, Mike Parker wrote:


Resources allocated for the process will be released on exit.


I see...but it is dependant on the OS right ? because I have seen 
other stuff relating to malloc as well, there are some out there 
that said that there is no need to free any more because the OS ( 
in this case windows ) will handle it




Re: how to create an array of scoped objects ?

2018-07-03 Thread Flaze07 via Digitalmars-d-learn

On Tuesday, 3 July 2018 at 10:00:00 UTC, Mike Parker wrote:


The only way you're going to be leaking resources is if the app 
is long running and the resource objects are never collected. 
I'd be more concerned about the nondeterministic nature of the 
destructor calls, particularly what happens at app shut down if 
the render window destructor is called before any thing that 
depends on the graphics context. If the library doesn't account 
for that, you'll get random crashes when the app exits.


If you need to release resources while the app is running, just 
use resource.destroy(). This will make sure the destructor is 
called and the object is reset to its init state, and you can 
maintain determinism.


hmm, I assume you know about DSFML, so... i.e

void main( string args[] ) {
auto win = new RenderWindow( VideoMode( 400, 400 ), "resource 
leak ?" );

win.close();
}
//in this context, is there any memory leak ? because I saw from 
the source that the render window is freed during the destructor 
calls


Re: how to create an array of scoped objects ?

2018-07-03 Thread Flaze07 via Digitalmars-d-learn

On Tuesday, 3 July 2018 at 07:03:43 UTC, vit wrote:

On Tuesday, 3 July 2018 at 02:13:21 UTC, Flaze07 wrote:

e.g A is a class that emits output during destruction
{
auto a = scoped!A();
}

how do I contain it in a container, in the Array struct ?

{
auto a = scoped!A();
Array!( typeof( a ) ) arr;
foreach( i ; 0..3 ) {
arr.insertBack( scoped!A );
}
}

is that how you do it ?



Copying/moving scoped!Class is very unsafe. scoped!Class is 
struct and have all of limitations of structs like no internal 
pointers to itself...

That's why it is not copyable.


that's interesting, but I am using dsfml by jebbs( not derelict 
), and I checked the code, it appears that the most of the class 
allocates resource and then freeing it in Destructor i.e


class RenderWindow {
private sfRenderWindow* _window;
public {
 this() {
_window = sfRenderWindow_create(/*parameters*/);
 }
 //couple of other functions
 ~this() {
 sfRenderWindow_destroy( window );
 }
}
}
//not a very accurate representation, but should get the message 
pretty clear


which I am very concerned about leaking resources, the tutorial 
did just not use scoped!, instead it directly use new, but what 
about leaking resources ?


how to create an array of scoped objects ?

2018-07-02 Thread Flaze07 via Digitalmars-d-learn

e.g A is a class that emits output during destruction
{
auto a = scoped!A();
}

how do I contain it in a container, in the Array struct ?

{
auto a = scoped!A();
Array!( typeof( a ) ) arr;
foreach( i ; 0..3 ) {
arr.insertBack( scoped!A );
}
}

is that how you do it ?


Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn

On Thursday, 28 June 2018 at 09:47:07 UTC, Jonathan M Davis wrote:
On Thursday, June 28, 2018 09:26:10 Flaze07 via 
Digitalmars-d-learn wrote:

On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote:
>   [...]

what about during runtime ?


Ranges in general have an arbitrary length, whereas tuples have 
a fixed length that is known at compile time. So, it really 
doesn't make sense to convert a range to a tuple. You can 
create function that takes the first x number of elements of a 
range (probably throwing if the range is too short) and create 
a tuple from those elements, but it would be a bit of a pain to 
do, and it would generally be a pretty weird thing to do. A 
dynamic array would make a lot more sense than a tuple.


- Jonathan M Davis


ok gotcha


Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn

On Thursday, 28 June 2018 at 09:42:54 UTC, Flaze07 wrote:

On Thursday, 28 June 2018 at 09:38:36 UTC, Stefan Koch wrote:

On Thursday, 28 June 2018 at 09:26:10 UTC, Flaze07 wrote:

On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote:

On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote:
is there some sort of ways to turn range into tuple ? ( an 
array preferably )

e.g
uint[] arr = [ 10, 20, 30 ];
auto tup = rangeToTup( arr );
assert( tup[ 0 ] == 10 );
assert( tup[ 1 ] == 20 );
assert( tup[ 2 ] == 30 );


https://dlang.org/phobos/std_meta#aliasSeqOf

--
  Simen


what about during runtime ?


Tuples are compile-time entities.
However if you just want an array use std.range.array.


that's interesting, thanks


the reason I am asking is that I want to do something similar to 
this code in python :

a, b, c = input().split(' ')
because I feel like reading with readln is easier than readf


Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn

On Thursday, 28 June 2018 at 09:38:36 UTC, Stefan Koch wrote:

On Thursday, 28 June 2018 at 09:26:10 UTC, Flaze07 wrote:

On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote:

On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote:
is there some sort of ways to turn range into tuple ? ( an 
array preferably )

e.g
uint[] arr = [ 10, 20, 30 ];
auto tup = rangeToTup( arr );
assert( tup[ 0 ] == 10 );
assert( tup[ 1 ] == 20 );
assert( tup[ 2 ] == 30 );


https://dlang.org/phobos/std_meta#aliasSeqOf

--
  Simen


what about during runtime ?


Tuples are compile-time entities.
However if you just want an array use std.range.array.


that's interesting, thanks


Re: turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn

On Thursday, 28 June 2018 at 08:52:33 UTC, Simen Kjærås wrote:

On Thursday, 28 June 2018 at 08:36:54 UTC, Flaze07 wrote:
is there some sort of ways to turn range into tuple ? ( an 
array preferably )

e.g
uint[] arr = [ 10, 20, 30 ];
auto tup = rangeToTup( arr );
assert( tup[ 0 ] == 10 );
assert( tup[ 1 ] == 20 );
assert( tup[ 2 ] == 30 );


https://dlang.org/phobos/std_meta#aliasSeqOf

--
  Simen


what about during runtime ?


turn range into tuple ?

2018-06-28 Thread Flaze07 via Digitalmars-d-learn
is there some sort of ways to turn range into tuple ? ( an array 
preferably )

e.g
uint[] arr = [ 10, 20, 30 ];
auto tup = rangeToTup( arr );
assert( tup[ 0 ] == 10 );
assert( tup[ 1 ] == 20 );
assert( tup[ 2 ] == 30 );


Re: what is the point of functor ?

2018-06-24 Thread Flaze07 via Digitalmars-d-learn
On Friday, 22 June 2018 at 20:20:56 UTC, Steven Schveighoffer 
wrote:

On 6/22/18 2:25 PM, Ali Çehreli wrote:

On 06/22/2018 08:17 AM, Steven Schveighoffer wrote:

 > reason to use functors

I wonder whether they are more efficient because a functor 
would carry just the state that it needs. Also, there is no GC 
memory allocation unless the programmer wants to.


I wonder how much state is allocated for a delegate?


If it's not a closure, then none. It just uses the stack frame.

Most of the time you would just use an alias instead of a 
functor or a delegate.


-Steve


I see, thank you


what is the point of functor ?

2018-06-22 Thread Flaze07 via Digitalmars-d-learn
recently, I visited the glossary and saw that functor exist in 
D...I know that functor exist C++ as a way to easily allow higher 
order function, but since D already has function and delegates, 
is there a point to functor ?


Re: using tuple as value type for associative array

2018-06-20 Thread Flaze07 via Digitalmars-d-learn

On Thursday, 21 June 2018 at 03:04:46 UTC, Computermatronic wrote:

On Thursday, 21 June 2018 at 02:44:12 UTC, Flaze07 wrote:

when I do
Tuple!(uint, "first", uint, "second")[string] what; //I tried 
aliasing the tuple as well

what["something"].first = 20;
I get range error
but when I do
uint[string] what2;
what2 = 20;
I get none of those range error, so...how do I use tuple as 
value type for associative array ?


what["something"].first = 20 will attempt to get an element of 
what, then assign a member, while what2["something"] = 20 will 
add an element to what2 with the value of 20. Since 
what["something"] is not present, it will throw a range error.


Try what["something"] = tuple(20, 0); instead.


huh, interesting, thanks


using tuple as value type for associative array

2018-06-20 Thread Flaze07 via Digitalmars-d-learn

when I do
Tuple!(uint, "first", uint, "second")[string] what; //I tried 
aliasing the tuple as well

what["something"].first = 20;
I get range error
but when I do
uint[string] what2;
what2 = 20;
I get none of those range error, so...how do I use tuple as value 
type for associative array ?


Re: remove not callable for char[]

2018-06-12 Thread Flaze07 via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:08:25 UTC, Steven Schveighoffer 
wrote:

On 6/12/18 2:33 AM, Flaze07 wrote:
well, not really, it just cannot auto deduce, the problem is, 
I don't know what to put in, I know that I can put in 
SwapStrategy.stable for the first one, but what about the 
Range, I don't know what to put in

E.g
int[] i = [ 1, 2 ];
i = i.remove( 1 );//able to automagically deduce

char[] c = [ 'a', 'b' ];
c = c.remove( 1 ); //unable to deduce what char[] is in range


The issue is that char[] is treated as an auto-decoding 
bi-directional range by Phobos, not an array.


To get Phobos to behave, you can use byCodeUnit:

import std.utf: byCodeUnit;

c = c.byCodeUnit.remove(1).source;

-Steve


I see, so it means that only char is affected, gotcha



remove not callable for char[]

2018-06-11 Thread Flaze07 via Digitalmars-d-learn
well, not really, it just cannot auto deduce, the problem is, I 
don't know what to put in, I know that I can put in 
SwapStrategy.stable for the first one, but what about the Range, 
I don't know what to put in

E.g
int[] i = [ 1, 2 ];
i = i.remove( 1 );//able to automagically deduce

char[] c = [ 'a', 'b' ];
c = c.remove( 1 ); //unable to deduce what char[] is in range


Re: how to sort the container Array from std.container

2018-06-08 Thread Flaze07 via Digitalmars-d-learn

On Wednesday, 6 June 2018 at 14:46:56 UTC, ag0aep6g wrote:

On 06/06/2018 04:20 PM, Flaze07 wrote:
hmm, and sorry for asking more, what about removing an element 
from it ? I found no remove operation that can remove from the 
middle ( removeAny and removeBack both removes the latest 
element, linearRemove receive Array!uint...which  don't know 
how to provide )


I think removeKey would be the container primitive for that. I 
don't know if there's a reason why it isn't implemented for 
Array. Maybe it's just an oversight.


You can use linearRemove like this:


import std.container.array: Array;
import std.stdio: writeln;
void main()
{
Array!int a = [1, 2, 100, 200, 300, 3, 4];
a.linearRemove(a[2 .. 5]);
/* Removes elements at indices 2, 3, and 4. */
writeln(a[]); /* Prints "[1, 2, 3, 4]". */
}



ah...well thank you, well...I did finds another way, but it is 
probably better to use linearRemove

I used
arr = make!( Array!uint )( remove( arr[], 2 );
so linearRemove is probably better


Re: how to sort the container Array from std.container

2018-06-06 Thread Flaze07 via Digitalmars-d-learn

On Wednesday, 6 June 2018 at 14:29:28 UTC, rikki cattermole wrote:

On 07/06/2018 2:27 AM, Flaze07 wrote:
On Wednesday, 6 June 2018 at 14:24:15 UTC, rikki cattermole 
wrote:

On 07/06/2018 2:20 AM, Flaze07 wrote:
On Wednesday, 6 June 2018 at 14:06:54 UTC, rikki cattermole 
wrote:

[...]


hmm, and sorry for asking more, what about removing an 
element from it ? I found no remove operation that can 
remove from the middle ( removeAny and removeBack both 
removes the latest element, linearRemove receive 
Array!uint...which  don't know how to provide )


filter will remove any and all occurrences of whatever you 
tell it to. But only in the range not the origin data 
structure.


what about removing certain index ?


Indexes and ranges don't usually go together.


welp, ok then, thank you


Re: how to sort the container Array from std.container

2018-06-06 Thread Flaze07 via Digitalmars-d-learn

On Wednesday, 6 June 2018 at 14:24:15 UTC, rikki cattermole wrote:

On 07/06/2018 2:20 AM, Flaze07 wrote:
On Wednesday, 6 June 2018 at 14:06:54 UTC, rikki cattermole 
wrote:

On 07/06/2018 1:58 AM, Flaze07 wrote:

[...]


Yes.


hmm, and sorry for asking more, what about removing an element 
from it ? I found no remove operation that can remove from the 
middle ( removeAny and removeBack both removes the latest 
element, linearRemove receive Array!uint...which  don't know 
how to provide )


filter will remove any and all occurrences of whatever you tell 
it to. But only in the range not the origin data structure.


what about removing certain index ?


Re: how to sort the container Array from std.container

2018-06-06 Thread Flaze07 via Digitalmars-d-learn

On Wednesday, 6 June 2018 at 14:06:54 UTC, rikki cattermole wrote:

On 07/06/2018 1:58 AM, Flaze07 wrote:

On Wednesday, 6 June 2018 at 13:46:41 UTC, Adam D. Ruppe wrote:

On Wednesday, 6 June 2018 at 13:44:09 UTC, Flaze07 wrote:

sort( arr.Range );
don't work, it says cannot pass RangeT!(Array!uint) as 
function argument


Range is the type, you want the value

I think you can do

sort(arr[])

maybe


I see why it works, so, [] is called slice operator right ?
and in 
https://dlang.org/phobos/std_container_array.html#.Array.opSlice it returns range, so that's why it worked


Yes.


hmm, and sorry for asking more, what about removing an element 
from it ? I found no remove operation that can remove from the 
middle ( removeAny and removeBack both removes the latest 
element, linearRemove receive Array!uint...which  don't know how 
to provide )


Re: how to sort the container Array from std.container

2018-06-06 Thread Flaze07 via Digitalmars-d-learn

On Wednesday, 6 June 2018 at 13:46:41 UTC, Adam D. Ruppe wrote:

On Wednesday, 6 June 2018 at 13:44:09 UTC, Flaze07 wrote:

sort( arr.Range );
don't work, it says cannot pass RangeT!(Array!uint) as 
function argument


Range is the type, you want the value

I think you can do

sort(arr[])

maybe


I see why it works, so, [] is called slice operator right ?
and in 
https://dlang.org/phobos/std_container_array.html#.Array.opSlice 
it returns range, so that's why it worked


how to sort the container Array from std.container

2018-06-06 Thread Flaze07 via Digitalmars-d-learn

I know that sort accepts Range( I am correct right ? ), so,
Array!uint arr;
//inserts element to arr
sort( arr.Range );
don't work, it says cannot pass RangeT!(Array!uint) as function 
argument