how do you append arrays?
asdf via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Feb 25 13:39:00 PST 2016
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 this morning but probably not very
efficient. You can see:
---- cut ----
debug = 0;
import std.stdio;
import std.string;
void main() {
string line;
string[] history;
char cmd = '/',
sep = ';',
dot = '.',
bak = '\\';
line = readln().chomp;
foreach(int i; 0..100) history ~= "";
debug(1) { stderr.writeln(history); }
while(!stdin.eof) {
string[] emit = line.split(sep);
foreach(string e; emit) {
/* how to do proper prefix and/or leading word? */
if(e[0] == cmd) { /* ... */ }
else if(e[0] == dot) { /* ... */ }
else if(e[0] == bak) { /* ... */ }
else writeln(e);
}
if(line != "" && line != history[0]) {
string[] x = [line];
foreach(string i; history[0..99]) x ~= i;
history = x;
}
debug(1) { stderr.writeln(history); }
line = readln().chomp;
}
}
---- cut ----
Is there a good way to pick out matching prefixes of a string?
Picking out the first word without disrupting whitespace after
the second word would be nice =)
How do you read chars without waiting for a newline? That would
be needed to respond to the ANSI esapes for arrow keys...
More information about the Digitalmars-d-learn
mailing list