Re: How to test tuple in chain

2017-07-31 Thread closescreen via Digitalmars-d-learn

I read my message. Sorry for my poor english and typos.


How to test tuple in chain

2017-07-31 Thread closescreen via Digitalmars-d-learn

Hello!

If I want testing tuple member in functional manner, what I shoul 
do?


Example:


"ls -l".executeShell returns me tuple (int "status", string 
"output")


I want write somthing like:

"ls -l".executeShell.smthTestingOperation!"Error: bad status."( 
res => res.status==0 ).output.writeln;


(where "smthTestingOperation" - is function which I want to find 
in std )





Bug in File.byRecord ?

2017-07-26 Thread closescreen via Digitalmars-d-learn

I have a file with empty lines: 2,3 and 5,6

filename.csv (with linenumbers for better view in this message)
1>Joe,Carpenter,30
2>
3>
4>Fred,Blacksmith,40
5>
6>

Now, if I run:
rdmd 
--eval='"filename.csv".File.byRecord!(string,string,int)("%s,%s,%d").writeln'


It prints:

[Tuple!(string, string, int)("Joe", "Carpenter", 30),
 Tuple!(string, string, int)("Joe", "Carpenter", 30),
 Tuple!(string, string, int)("Joe", "Carpenter", 30),
 Tuple!(string, string, int)("Fred", "Blacksmith", 40),
 Tuple!(string, string, int)("Fred", "Blacksmith", 40),
 Tuple!(string, string, int)("Fred", "Blacksmith", 40)]

It happens because code in

https://github.com/dlang/phobos/blob/master/std/stdio.d#L297

not checks return value after call formattedRead.

Is this a bug? Or I not understand something?




Commandline args to rdmd --eval=...

2017-07-20 Thread closescreen via Digitalmars-d-learn

Hello, all.
Is it possible to pass cli args to rdmd eval-program?

F.e. if I try:

rdmd --eval="args.writeln" -- 123

then: Cannot have both --eval and a program file ('123')

In perl it's possible:

perl -e'print join ",", @ARGV' 123 234

# 123,234


Re: Add property setting to chain

2017-07-16 Thread closescreen via Digitalmars-d-learn

Thanks for reply, Ali.


Re: Add property setting to chain

2017-07-15 Thread closescreen via Digitalmars-d-learn

I found this solution:

Clock.currTime.to!DateTime.pipe!( dt=>(dt.minute=0,dt.second=0, 
dt) ).Interval!DateTime( 24.hours ).fwdRange( h=>h+1.hours 
).writeln;


Or:

Clock.currTime.to!DateTime.pipe!( "a.minute=0, a.second=0, a" 
).Interval!DateTime( 24.hours ).fwdRange( h=>h+1.hours ).writeln;




Is this code looks good, idiomatic?


Add property setting to chain

2017-07-15 Thread closescreen via Digitalmars-d-learn

Let i have code:

Clock.currTime.to!DateTime.Interval!DateTime( 24.hours 
).fwdRange( h=>h+1.hours ).writeln;


Now if i want to set the minute=0 and second=0 without breaking 
chain, what i should do?



I think about somewhat like:

with( Clock.currTime.to!DateTime){
 minute=0;
 second=0
}.Interval!DateTime( 24.hours ).fwdRange( h=>h+1.hours ).writeln;

But it is wrong, because 'with' not return me anything.