Re: why does this compile fine, but dies when you run it.

2018-03-22 Thread steven kladitis via Digitalmars-d-learn

On Wednesday, 21 March 2018 at 18:55:34 UTC, Adam D. Ruppe wrote:
On Wednesday, 21 March 2018 at 18:53:39 UTC, steven kladitis 
wrote:

int[] array3;
array3[0]=4;


array3 is empty. You are trying to set a value that doesn't 
exist..


import std.stdio;

void main(){
int[3] array1 = [ 10, 20, 30 ];
auto array2 = array1; // array2's elements are different
// from array1's
array2[0] = 11;
int[] array3;
//array4[0]=3;
array3 ~=4;
auto array4 = array3;
array4 ~=2;
int[string] a1;
int[int] a2;

a1["V"]=2;
a2[4]=3;

writeln(array1,'\n',array2,'\n',array3,'\n',array4,'\n',a1,'\n',a2);
}

-- this works, why??
-- what is the difference between int[] x; and int[int] x; 
-- thanks
-- Steven


why does this compile fine, but dies when you run it.

2018-03-21 Thread steven kladitis via Digitalmars-d-learn

import std.stdio;

void main(){
int[3] array1 = [ 10, 20, 30 ];
auto array2 = array1; // array2's elements are different
// from array1's
array2[0] = 11;
int[] array3;
//array4[0]=3;
array3[0]=4;
auto array4 = array3;

writeln(array1,'\n',array2,'\n',array3,'\n',array4);
}


-- windows 7 64 bit ( os ) dmd 2.079.0
-- thanks
-- Steven


Re: trying to use nightly in windows 10 x64

2017-03-18 Thread steven kladitis via Digitalmars-d-learn

On Saturday, 18 March 2017 at 15:26:42 UTC, steven kladitis wrote:

before trying nightly
I run the c:\d\dmd2vars32.bat or c:\d\dmd2vars64.bat 
respectively.

and I can compile an run either 32 or 64 bit executables.
now I want to try nightly

I renamed the  current dmd directory in c:\d to dmd_current
I extracted the 7z file for nightly into c:\d
the 32 bit appears to work, but the 64 bit now complains about 
c:\bin\link.exe
I run the c:\d\dmd2vars32.bat or c:\d\dmd2vars64.bat 
respectively.

Why does the 64 bit no longer compile at all?


TIA,
Steven


I found the problem, it is the sc.ini file in -> 
C:\D\dmd2\windows\bin
I think it would better to keep this file in c:\d or be able to 
tell dmd where to find it.
copying the sc.ini  to the nightly c:\dmd2\windows\bin solved the 
64 bit compile issues.




trying to use nightly in windows 10 x64

2017-03-18 Thread steven kladitis via Digitalmars-d-learn

before trying nightly
I run the c:\d\dmd2vars32.bat or c:\d\dmd2vars64.bat respectively.
and I can compile an run either 32 or 64 bit executables.
now I want to try nightly

I renamed the  current dmd directory in c:\d to dmd_current
I extracted the 7z file for nightly into c:\d
the 32 bit appears to work, but the 64 bit now complains about 
c:\bin\link.exe

I run the c:\d\dmd2vars32.bat or c:\d\dmd2vars64.bat respectively.
Why does the 64 bit no longer compile at all?


TIA,
Steven


Re: I do not understand what the problem is in this code.

2017-03-03 Thread steven kladitis via Digitalmars-d-learn

On Friday, 3 March 2017 at 04:14:02 UTC, Jordan Wilson wrote:

On Friday, 3 March 2017 at 03:11:24 UTC, steven kladitis wrote:

[...]


I saw this answer for a similar question from Adam D. Ruppe:
Quote:
"...it is anything that Phobos considers "bidirectional" and 
"swappable" - an array it can reverse easily and swap 
individual elements, and it considers plain string to be 
non-swappable due to UTF-8 encoding. Due to its variable length 
element encoding, swapping two chars may require reshuffling 
the entire array, which would be far more expensive than the 
function allows.


[...]


added std.conv and it works!! thanks for the help!!!


I do not understand what the problem is in this code.

2017-03-02 Thread steven kladitis via Digitalmars-d-learn

void main() {
import std.stdio, std.range, std.algorithm, std.string;

const pieces = "KQRrBbNN";
alias I = indexOf;
auto starts = permutations(pieces.dup).filter!(p =>
I(p, 'B') % 2 != I(p, 'b') % 2 && // Bishop 
constraint.

// King constraint.
((I(p, 'r') < I(p, 'K') && I(p, 'K') < I(p, 'R')) ||
 (I(p, 'R') < I(p, 'K') && I(p, 'K') < I(p, 'r'
.map!toUpper.array.sort().uniq;
writeln(starts.walkLength, "\n", starts.front);
}


Merry Christmas

2015-12-23 Thread steven kladitis via Digitalmars-d-learn

Twas the Night before Christmas and all through my D code.
The compiler was compiling the new and the olde.
Thanks to Walter,  Alexander and Ali.
I try to write more D code with happiness and Glee.
In the forums with help from folks like me galore.
I find I am not crazy, just need to learn more.
So with all my D code, bugs and all.
As long as I can compile and stay awake and from my chair not 
fall.

May all your code work be fast and work as fast as light.
I wish to All a Merry Christmas and to All a good night.


Lots of D code

2015-12-22 Thread steven kladitis via Digitalmars-d-learn
I have 843 programs written in D. 805 actually create an 32 bit 
exe in windows 10. I am running the latest D.  Some just start to 
link and the linker disappears. Some just have issues I am  not 
able figure out. I can attach the code and scripts I use to 
compile and run these. If anyone is willing to figure out why the 
38 do not compile, I would appreciate code that works.  The 
execute_bf_v2.d creates an exe that is small but takes about 1 
hour to link on a 12 core processor with 64g of ram as 14tb of 
disk space. The rest link very fast.  If anyone is interested, 
let me know.  I would love to get the 38 working.  Also there are 
a few that produce incorrect answers.  The Generate_maze.d  
produces all but the last line of the maze.  I added a line just 
for it.  I do not understand why.  All of the programs are from 
RosettaCode.org. The  script to compile them generates a log file 
and you will see a few that the linker just stops No idea 
why. A few have 64K link errors no idea why.



TIA,
Steven


Re: why does this error out?

2015-11-10 Thread steven kladitis via Digitalmars-d-learn

On Tuesday, 10 November 2015 at 05:14:29 UTC, lobo wrote:

On Tuesday, 10 November 2015 at 04:34:22 UTC, Cauterite wrote:

Here's the output I get (DMD v2.068.2):

[1, 3, 10, 12, 21, 30, 100, 102, 111, 120, 201, 210]
core.exception.AssertError@std\range\package.d(4603): 
Assertion failure


iota.front() is complaining the range is empty from this line.

harshads.filter!(h => h > 1000).front.writeln;

your hardas has no values > 1000 so the filter is empty. 
hardwas was seeded with iota(1,256), so the maximum value will 
be 252.


bye,
lobo



with dmd 2.069
I always get
--> [1
and then the error no matter what I canhe that line to.


why does this error out?

2015-11-09 Thread steven kladitis via Digitalmars-d-learn

void main() {
import std.stdio, std.algorithm, std.range, std.conv;

enum digSum = (int n) => n.text.map!(d => d - '0').sum;
//enum harshads = iota(1, int.max).filter!(n => n % digSum(n) 
== 0);

enum harshads = iota(1, 256).filter!(n => n % digSum(n) == 0);
harshads.take(20).writeln;
harshads.filter!(h => h > 1000).front.writeln;
}

// this compiles but always prints 1 number and gets 
object.Error@(0): Access Violation


Re: Align a variable on the stack.

2015-11-06 Thread steven kladitis via Digitalmars-d-learn

On Friday, 6 November 2015 at 01:17:20 UTC, TheFlyingFiddle wrote:

On Friday, 6 November 2015 at 00:43:49 UTC, rsw0x wrote:
On Thursday, 5 November 2015 at 23:37:45 UTC, TheFlyingFiddle 
wrote:
On Thursday, 5 November 2015 at 21:24:03 UTC, TheFlyingFiddle 
wrote:

[...]


I reduced it further:

[...]


these run at the exact same speed for me and produce identical 
assembly output from a quick glance

dmd 2.069, -O -release -inline


Are you running on windows?

I tested on windows x64 and there I also get the exact same 
speed for both functions.


I am still disappointed that DMD is not native 64 bit in windows 
yet.  Please show exactly how you are getting 64 bit to work in 
windows 10. I have never gotten this to work.  for any version of 
DMD.   All of my new $400.00 systems are 4 gig 64 bit windows 
10...and the processor instruction sets are very nice.  I 
dabble in assembler.   I have always wondered why D does not take 
advantage of newer instructions.. and 64 bit. I see a 64 Bit 
droid Compiler for D.  :):):)


Re: good reasons not to use D?

2015-11-03 Thread steven kladitis via Digitalmars-d-learn

On Monday, 2 November 2015 at 17:09:41 UTC, Laeeth Isharc wrote:
On Saturday, 31 October 2015 at 16:06:47 UTC, Russel Winder 
wrote:
On Sat, 2015-10-31 at 15:41 +, tcak via 
Digitalmars-d-learn wrote:

[...]


In that std.bigint.BigInt provides the accuracy, yes it does 
suffice. But it is slow. As far as I am aware only IBM Big 
Iron (aka mainframes, aka z-Series) has hardware decimal 
floating point these days. (Even though 1970s and 1980s 
microprocessors had the feature.)


It would be nice to have fixed point numbers in Phobos, 
although it's not much work to implement, and there is a 
library solution already (which is maintained, but sometimes 
for a while breaks with newer versions of dmd).


I am Big Proponent of decimal arithmetic. It should be a breeze 
for a some of the smart folks using D. :):)


how to make the commented out lines work when they are uncommented

2015-11-02 Thread steven kladitis via Digitalmars-d-learn
import std.stdio, std.algorithm, std.array, std.traits,std.range, 
std.typecons,std.complex;


enum AreSortableArrayItems(T) = isMutable!T &&
__traits(compiles, T.init < 
T.init) &&

!isNarrowString!(T[]);

void selectionSort(T)(T[] data) if (AreSortableArrayItems!T) {
foreach (immutable i, ref d; data)
data.drop(i).minPos[0].swap(d);
}
void main() {
auto a = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2];
a.selectionSort;
a.writeln;
int[] a0;
a0.selectionSort;
a0.writeln;

auto a1 = [1];
a1.selectionSort;
a1.writeln;

auto a2 = ["a", "b"];
a2.selectionSort;
a2.writeln;

auto a3 = ["b", "a"];
a3.selectionSort;
a3.writeln;

//char[] a4 = ['a', 'b'];
//a4.selectionSort;
//a4.writeln;

dstring[] a5 = ["b", "a"];
a5.selectionSort;
a5.writeln;


alias Nullable!int N;
auto a6 = [N(2), N(1)];
a6.selectionSort; // Not nothrow.
a6.writeln;

//auto a7 = [complex(1.0,0.0), complex(2.0,0.0)];
//a7.selectionSort;
//a7.writeln;


//  auto a8 = [complex(1.0L), complex(2.0L)];
//a8.selectionSort;
//a8.writeln;


static struct F {
int x;
int opCmp(F f) { // Not pure.
return x < f.x ? -1 : (x > f.x ? 1 : 0);
}
}
auto a9 = [F(2), F(1)];
a9.selectionSort;
a9.writeln;
}
// dmd 2.069 rc2


what is wrong with this code??

2015-10-17 Thread steven kladitis via Digitalmars-d-learn
import std.string, std.typecons, std.exception, 
std.algorithm,std.stdio;

import std.traits: hasIndirections;

struct GrowableCircularQueue(T) {
public size_t length;
private size_t first, last;
private T[] A = [T.init];

this(T[] items...) pure nothrow @safe {
foreach (x; items)
push(x);
}

@property bool empty() const pure nothrow @safe @nogc {
return length == 0;
}

@property T front() pure nothrow @safe @nogc {
assert(length != 0);
return A[first];
}

T opIndex(in size_t i) pure nothrow @safe @nogc {
assert(i < length);
return A[(first + i) & (A.length - 1)];
}

void push(T item) pure nothrow @safe {
if (length >= A.length) { // Double the queue.
immutable oldALen = A.length;
A.length *= 2;
if (last < first) {
A[oldALen .. oldALen + last + 1] = A[0 .. last + 
1];

static if (hasIndirections!T)
A[0 .. last + 1] = T.init; // Help for the GC.
last += oldALen;
}
}
last = (last + 1) & (A.length - 1);
A[last] = item;
length++;
}

@property T pop() pure nothrow @safe @nogc {
assert(length != 0);
auto saved = A[first];
static if (hasIndirections!T)
A[first] = T.init; // Help for the GC.
first = (first + 1) & (A.length - 1);
length--;
return saved;
}
}


const struct Board {
private enum El { floor = ' ', wall = '#', goal = '.',
  box = '$', player = '@', boxOnGoal='*' }
private alias CTable = string;
private immutable size_t ncols;
private immutable CTable sData, dData;
private immutable int playerx, playery;

this(in string[] board) immutable
in {
foreach (const row; board) {
assert(row.length == board[0].length,
   "Unequal board rows.");
foreach (immutable c; row)
assert(c.inPattern(" #.$@*"), "Not valid input");
}
} body {
/*static*/ immutable sMap =
[' ':' ', '.':'.', '@':' ', '#':'#', '$':' '];
/*static*/ immutable dMap =
[' ':' ', '.':' ', '@':'@', '#':' ', '$':'*'];
ncols = board[0].length;
writeln("ncols =",ncols);
int plx = 0, ply = 0;
CTable sDataBuild, dDataBuild;

foreach (immutable r, const row; board)
foreach (immutable c, const ch; row) {
sDataBuild ~= sMap[ch];
dDataBuild ~= dMap[ch];
if (ch == El.player) {
plx = c;
ply = r;
}
//   writeln("c ch row ",c," ",ch," ",row);
//   writeln("board =>",board);
}


this.sData = sDataBuild;
this.dData = dDataBuild;
this.playerx = plx;
this.playery = ply;
}

private bool move(in int x, in int y, in int dx,
  in int dy, ref CTable data)
const pure nothrow /*@safe*/ {
if (sData[(y + dy) * ncols + x + dx] == El.wall ||
data[(y + dy) * ncols + x + dx] != El.floor)
return false;

auto data2 = data.dup;
data2[y * ncols + x] = El.floor;
data2[(y + dy) * ncols + x + dx] = El.player;
data = data2.assumeUnique; // Not enforced.
return true;
}

private bool push(in int x, in int y, in int dx,
  in int dy, ref CTable data)
const pure nothrow /*@safe*/ {
if (sData[(y + 2 * dy) * ncols + x + 2 * dx] == El.wall ||
data[(y + 2 * dy) * ncols + x + 2 * dx] != El.floor)
return false;

auto data2 = data.dup;
data2[y * ncols + x] = El.floor;
data2[(y + dy) * ncols + x + dx] = El.player;
data2[(y + 2 * dy) * ncols + x + 2*dx] = El.boxOnGoal;
data = data2.assumeUnique; // Not enforced.
return true;
}

private bool isSolved(in CTable data)
const pure nothrow @safe @nogc {
foreach (immutable i, immutable d; data)
if ((sData[i] == El.goal) != (d == El.boxOnGoal))
return false;
return true;
}

string solve() pure nothrow /*@safe*/ {
bool[immutable CTable] visitedSet = [dData: true];

alias Four = Tuple!(CTable, string, int, int);
GrowableCircularQueue!Four open;
open.push(Four(dData, "", playerx, playery));

static immutable dirs = [tuple( 0, -1, 'u', 'U'),
 tuple( 1,  0, 'r', 'R'),
 tuple( 0,  1, 'd', 'D'),
 tuple(-1,  0, 'l', 'L')];

while (!open.empty) {
//immutable (cur, cSol, x, y) = open.pop;
immutable item = open.pop;
immutable cur = item[0];
immutable cSol = item[1];
immutable x = 

Re: what is wrong with this code??

2015-10-17 Thread steven kladitis via Digitalmars-d-learn

On Saturday, 17 October 2015 at 14:47:11 UTC, anonymous wrote:

On Saturday, October 17, 2015 04:17 PM, steven kladitis wrote:


// it thows a range exception


On which line?


core.exception.RangeError@sokuban.d(84): Range violation


Re: what is wrong with this code??

2015-10-17 Thread steven kladitis via Digitalmars-d-learn

On Saturday, 17 October 2015 at 14:59:41 UTC, anonymous wrote:

On Saturday, October 17, 2015 04:50 PM, steven kladitis wrote:


core.exception.RangeError@sokuban.d(84): Range violation


Line 84 being this:

sDataBuild ~= sMap[ch];


Where sMap is:

/*static*/ immutable sMap =
[' ':' ', '.':'.', '@':' ', '#':'#', '$':' '];


Apparently, ch is some char that's not a key in sMap. Try 
printing out ch to see what it is exactly. Then, assuming it's 
really not a key in sMap, figure out if sMap should have that 
key, or if ch should not end up with that value.


Yes!!! Now it makes sense!!!  Thanks


Re: problem with exceptions

2015-10-02 Thread steven kladitis via Digitalmars-d-learn

On Friday, 2 October 2015 at 12:18:36 UTC, Dmitri wrote:
On Friday, 2 October 2015 at 11:44:21 UTC, steven kladitis 
wrote:

C:\d\examples>pb2
=>main's first line
  =>makeOmelet's first line
=>prepareAll's first line
  =>prepareEggs's first line
object.Exception@pb2.d(64): Cannot take -8 eggs from the fridge

0x00402252
0x0040512F
0x00405043
0x00403E48
0x7600338A in BaseThreadInitThunk
0x77A497F2 in RtlInitializeExceptionChain
0x77A497C5 in RtlInitializeExceptionChain


- I always see the info at the bottom. Is this normal. I 
was thinkig I should only the the exception message itself.

---  this is windows 7 32 bit.


that would the stack of the thread leading up to the exception. 
I think you get that if you dump the exception object itself 
(not just the message).


-- code is below
import std.stdio;
import std.string;

void indent(in int level)
{
foreach (i; 0 .. level * 2)
{
write(' ');
}
}
void entering(in char[] functionName, in int level)
{
indent(level);
writeln("=>", functionName, "'s first line");
}
void exiting(in char[] functionName, in int level)
{
indent(level);
writeln("<=", functionName, "'s last line");
}
void main()
{
entering("main", 0);
makeOmelet(-8);
eatOmelet();
exiting("main", 0);
}
void makeOmelet(int eggCount)
{
entering("makeOmelet", 1);
prepareAll(eggCount);
cookEggs();
cleanAll();
exiting("makeOmelet", 1);
}
void eatOmelet()
{
entering("eatOmelet", 1);
exiting("eatOmelet", 1);
}
void prepareAll(int eggCount)
{
entering("prepareAll", 2);
prepareEggs(eggCount);
prepareButter();
preparePan();
exiting("prepareAll", 2);
}
void cookEggs()
{
entering("cookEggs", 2);
exiting("cookEggs", 2);
}
void cleanAll()
{
entering("cleanAll", 2);
exiting("cleanAll", 2);
}
void prepareEggs(int count)
{
entering("prepareEggs", 3);
if (count < 1)
{
throw new Exception(
  format("Cannot take %s eggs from the fridge", 
count));

}
exiting("prepareEggs", 3);
}
void prepareButter()
{
entering("prepareButter", 3);
exiting("prepareButter", 3);
}
void preparePan()
{
entering("preparePan", 3);
exiting("preparePan", 3);
}



problem with exceptions

2015-10-02 Thread steven kladitis via Digitalmars-d-learn

C:\d\examples>pb2
=>main's first line
  =>makeOmelet's first line
=>prepareAll's first line
  =>prepareEggs's first line
object.Exception@pb2.d(64): Cannot take -8 eggs from the fridge

0x00402252
0x0040512F
0x00405043
0x00403E48
0x7600338A in BaseThreadInitThunk
0x77A497F2 in RtlInitializeExceptionChain
0x77A497C5 in RtlInitializeExceptionChain


- I always see the info at the bottom. Is this normal. I was 
thinkig I should only the the exception message itself.

---  this is windows 7 32 bit.





question about multiple alias this

2015-09-24 Thread steven kladitis via Digitalmars-d-learn

class A{
  int i;
  bool b;
  alias i this;
  alias b this;
}

void main()
{
  auto a = new A;
  int i = a;
  bool b = a;
}

--- this will not compile in dmd 2068.1.
--- ok, but what technique do you use to emulate this type of 
behavior??
--- would interfaces be the answer, if so could I see an example. 
and would you use the

--- same for structs ??
--- thanks, Steven


Re: number formatting

2014-04-20 Thread steven kladitis via Digitalmars-d-learn

Note sure if you can edit messages once sent.

 $13,456.67
 245,678,541


On Sunday, 20 April 2014 at 12:50:52 UTC, steven kladitis wrote:

How do you format numbers to have things like.
 Leading $ or , or CR with or without leading zeros.
  for example $56.00
  $056.00
  $1,3456.67
  345.89CR




number formatting

2014-04-20 Thread steven kladitis via Digitalmars-d-learn

How do you format numbers to have things like.
 Leading $ or , or CR with or without leading zeros.
  for example $56.00
  $056.00
  $1,3456.67
  345.89CR



Re: arrays in DMD V2

2014-04-19 Thread steven kladitis via Digitalmars-d-learn

void main()
{

//inta0[];
int[] a0;
//inta1[][];
int[][] a1;
//string a2[][];
string[][] a2;
//string a3[][string];
string[string] a3;
//  string[][string] a3;
// possibly should be above for a3
//string a4[][string][string];
string[][string][string] a4;
//string a4[string][string][string]; is this the same as above
//inta5[][string][string][string];
int[][string][string][string] a5;
//inta6[string][int][string][float];
int[string][int][string][float] a6;
//inta7[int][int][string];
int[int][int][string] a7;


// how do you initialize each array, what type are they 
multidimensional???
// how do you define all of the above with limits on each 
dimension???


a0  = [1,2,3];
// works
writeln( a0 );

a1  = [ [ 1,2,3 ],[4,5,6]];
// works
writeln( a1 );

a2  = [ [a,b ],[ c,d ] ];
//works
writeln ( a2 );

a3  = [ a:b,c:d];
// works
writeln ( a3 );

a4= [ a:[b:[c ]]];
//works
writeln( a4 );

//a5= [ 1 :[a:[b:[c ;
// does not work
writeln(a5);

//  pragma(msg, typeof(a0));
//  pragma(msg, typeof(a1));
//  pragma(msg, typeof(a2));
//  pragma(msg, typeof(a3));
//  pragma(msg, typeof(a4));
//  pragma(msg, typeof(a5));
//  pragma(msg, typeof(a6));
//  pragma(msg, typeof(a7));


//a6= [ 1,[a,1,b,4.0]];
// does not work
//a6 = [a: [1: [b: [4.0: 5;
// does not work
writeln(a6);


//a7 = [ 1,1,a];
// does not work
//a7 = [1: 2[:3]];
// does not work
writeln(a7);


// in DMD 2.065
// not sure how to initialize 5,6,7



}


Re: arrays in DMD V2

2014-04-19 Thread steven kladitis via Digitalmars-d-learn

Fantastic

I am getting a much clearer picture of arrays I appreciate 
all of the help
I see many examples of D online, but most do not compile under 
2.065.  I am wondering if there is a D manual or book just for D 
V2.0.


arrays in DMD V2

2014-04-18 Thread steven kladitis via Digitalmars-d-learn

import std.stdio;


void main()
{

inta0[];
inta1[][];
string a2[][];
string a3[][string];
string a4[][string][string];
//string a4[string][string][string]; is this the same as above
inta5[][string][string][string];
inta6[string][int][string][float];
inta7[int][int][string];

// how do you initialize each array, what type are they 
multidimensional???
// how do you define all of the above with limits on each 
dimension???




}

//help please


Re: arrays in DMD V2

2014-04-18 Thread steven kladitis via Digitalmars-d-learn
Thanks, I am trying to understand what I am doing. The docs seem 
unclear to me on how to initialize these.  I think there are 
three ways.

 with brackets , the other with foreach or direct assignments.
-- here is a longer version
-- uncomment out the assignments to see the errors I get.
-- I am trying to understand arrays.



On Saturday, 19 April 2014 at 01:13:55 UTC, Jesse Phillips wrote:
On Saturday, 19 April 2014 at 00:27:32 UTC, steven kladitis 
wrote:

import std.stdio;


void main()
{

inta0[];
inta1[][];
string a2[][];
string a3[][string];
string a4[][string][string];
//string a4[string][string][string]; is this the same as 
above

inta5[][string][string][string];
inta6[string][int][string][float];
inta7[int][int][string];

// how do you initialize each array, what type are they 
multidimensional???
// how do you define all of the above with limits on each 
dimension???

}

//help please


First, don't use that syntax. everything should be placed on 
the type:


Second,

void main() {
inta5[][string][string][string];
pragma(msg, typeof(a5));
}

Third,

http://dlang.org/arrays.html
http://dlang.org/hash-map.html




Re: arrays in DMD V2

2014-04-18 Thread steven kladitis via Digitalmars-d-learn

import std.stdio;


void main()
{

inta0[];
inta1[][];
string a2[][];
string a3[][string];
string a4[][string][string];
//string a4[string][string][string]; is this the same as above
inta5[][string][string][string];
inta6[string][int][string][float];
inta7[int][int][string];

// how do you initialize each array, what type are they 
multidimensional???
// how do you define all of the above with limits on each 
dimension???


a0  = [1,2,3];
//writefln( a0 );

a1  = [ [ 1,2,3 ],[4,5,6]];
//writefln( a1 );

a2  = [ [a,b ],[ c,d ] ];

//writefln ( a2 );

//a3  = [ [a,b ],[ c,d ] ];
// does not work

//a4= [ [a,b ];
// does not work.

//a5  = [ [1,a,b]];

  pragma(msg, typeof(a0));
   pragma(msg, typeof(a1));
pragma(msg, typeof(a2));
 pragma(msg, typeof(a3));
  pragma(msg, typeof(a4));
   pragma(msg, typeof(a5));
pragma(msg, typeof(a6));
 pragma(msg, typeof(a7));
//  does not work

//a6= [ 1,[a,1,b,4.0]];
// does not work


//a7 = [ 1,1,a];
// does not work


// also how would you do in a foreach?



}