Re: Error with associative array initializer DMD32 D Compiler v2.070.0

2016-03-03 Thread asdf via Digitalmars-d-learn
On Thursday, 3 March 2016 at 10:35:50 UTC, MGW wrote: The citation from https://dlang.org/spec/hash-map.html Static Initialization of AAs immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; unittest { assert(aa["foo"] == 5);

Re: Error with associative array initializer DMD32 D Compiler v2.070.0

2016-03-03 Thread asdf via Digitalmars-d-learn
On Thursday, 3 March 2016 at 10:01:47 UTC, MGW wrote: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; ... Error: non-constant expression ["foo":5L, "bar":10L, "baz":2000L] D associative arrays are a dynamic runtime feature, thus can't be initialized without

Weird struct stuff

2016-03-02 Thread asdf via Digitalmars-d-learn
import std.stdio : writeln; struct foo { long* bar; this (long l) { long d = l; bar = } } int main() { foo f = foo(12345); writeln(*f.bar); //writefoo(f); writeln(*f.bar); return 0; } void writefoo(foo f) { writeln(*f.bar); } If I

Re: how do you append arrays?

2016-02-26 Thread asdf via Digitalmars-d-learn
On Friday, 26 February 2016 at 00:40:40 UTC, Steven Schveighoffer wrote: ugh! history = line ~ history[0 .. $ - 1]; That works alot better =) Trying to uncook the terminal failed however. It can't recognize struct tag-declarations I think: /* copy-paste code from:

Re: dub: how to reference a compiled package

2016-02-25 Thread asdf via Digitalmars-d-learn
On Friday, 26 February 2016 at 04:03:15 UTC, BBasile wrote: e.g the DMD equivalent for the two previous example is DMD "sourceThis.d" "folder/interface.di" "folder/binary.a" -ofbin/thesoft You can mix unlinked binaries and text-editor source files on commandline? Didn't know that when I

Re: Calling python code from D

2016-02-25 Thread asdf via Digitalmars-d-learn
On Thursday, 25 February 2016 at 21:46:40 UTC, asdf wrote: Hi, me again. I'm having trouble making a demonstration and not sure if is obsolete or not anyways. :/ Anyways take a look here. http://www.tutorialspoint.com/python/python_further_extensions.htm

Re: Calling python code from D

2016-02-25 Thread asdf via Digitalmars-d-learn
On Thursday, 25 February 2016 at 21:40:45 UTC, Wyatt wrote: I have a project I started in Python before I realised I really don't enjoy Python. It's been on the back-burner for a few years and I'd like to start again in D, but there's a particular python module (Mutagen) that I outright

Re: how do you append arrays?

2016-02-25 Thread asdf via Digitalmars-d-learn
On Thursday, 25 February 2016 at 19:21:31 UTC, Steven Schveighoffer wrote: On 2/25/16 2:12 PM, Steven Schveighoffer wrote: I believe you could use std.algorithm.copy, but probably need to do it with retro as well. Heh, or of course use memmove :) -Steve I got the history list working

Re: How to detect if an array if dynamic or static

2016-02-25 Thread asdf via Digitalmars-d-learn
On Wednesday, 24 February 2016 at 21:48:14 UTC, mahdi wrote: Suppose we have a function like this: void diss(int[] array) ... How can we detect is `array` is static (fixed size) or dynamic, inside the function body? I don't understand what I'm doing but got a proof of concept for you. This

Re: how do you append arrays?

2016-02-25 Thread asdf via Digitalmars-d-learn
On Thursday, 25 February 2016 at 13:06:10 UTC, cym13 wrote: In D the binary operator "~" is used to concatenate both strings (arrays of characters) and arrays. (also the ~= operator is equivalent to lhs = lhs ~ rhs Nic Just a precision: "lhs ~= rhs" isn't exactly equivalent to "lhs =

Re: how do you append arrays?

2016-02-25 Thread asdf via Digitalmars-d-learn
On Thursday, 25 February 2016 at 12:58:54 UTC, Nicholas Wilson wrote: In D the binary operator "~" is used to concatenate both strings (arrays of characters) and arrays. (also the ~= operator is equivalent to lhs = lhs ~ rhs Nic It worked! A link from someone else's question suggested

how do you append arrays?

2016-02-25 Thread asdf via Digitalmars-d-learn
I'm trying to make a terminal input preprocessor with alias/shortcuts and history. import std.stdio; void main() { string line; string[] history; line = readln(); foreach(int i; 0..100) history = history + [""]; // XXX while(!stdin.eof) { writeln(line);

Re: Weird multithreading stuff

2016-01-29 Thread asdf via Digitalmars-d-learn
Okay so it turns out putting something in another thread is like throwing it into an alternate universe where only my functions exist, and instead of telling me my data doesn't exist, it just silently behaves as if it's all empty Man, threads are weird. I'll just pass the data in as an

Re: Weird multithreading stuff

2016-01-29 Thread asdf via Digitalmars-d-learn
Okay it somehow just got even stranger that condition 'tokenIsAnOperator' in that code is a function to test whether the token is contained within the array ["+", "-", "*", "/"] It seems that sometimes it returns true for "*", and sometimes false, but only when I have "parallel" in that

Re: Weird multithreading stuff

2016-01-29 Thread asdf via Digitalmars-d-learn
On Saturday, 30 January 2016 at 05:41:10 UTC, tsbockman wrote: On Saturday, 30 January 2016 at 05:15:58 UTC, asdf wrote: Okay so it turns out putting something in another thread is like throwing it into an alternate universe where only my functions exist, and instead of telling me my data

Weird multithreading stuff

2016-01-29 Thread asdf via Digitalmars-d-learn
I'm writing a program to parse and evaluate mathematical expressions the parse tree is in the format: struct node { string token; node*[] children; } it is parsed such that for the input 1*(2+3)-4*(5+6), the tree ends up looking like - * * 1 + 4 +