digitalmars.D.learn - Clock.currTime
- Kent (10/10) Nov 20 2014 I am reading the book 《D Cookbook》
- bearophile (6/10) Nov 20 2014 Perhaps:
- Kent (3/14) Nov 20 2014 Thank you for your reply.
- Adam D. Ruppe (6/10) Nov 20 2014 Are you sure you saw the important difference? There was a >> in
- Kent (17/28) Nov 20 2014 I have notice the difference.Changed the ">>" to ">".
- Adam D. Ruppe (5/7) Nov 20 2014 Oh, there shouldn't be a ! there either. Should be take(10), not
- Kent (10/17) Nov 20 2014 Thank you very much for help me.
I am reading the book 《D Cookbook》 In Page 36,this code can't be complied: auto filtered = filter!((a) => Clock.currTime() - a.timeLastModified >> 14.days)(sorted); "sorted"'s type is DirEntry[]. The errors : Error 1 Error: 'currTime(cast(immutable(TimeZone))opCall()).opBinary(a.timeLastModified())' is not of integral type, it is a Duration I don't know what's the problem?
Nov 20 2014
Kent:I am reading the book 《D Cookbook》 In Page 36,this code can't be complied: auto filtered = filter!((a) => Clock.currTime() - a.timeLastModified >> 14.days)(sorted);Perhaps: mySorted.filter!(a => Clock.currTime - a.timeLastModified > 14.days); Bye, bearophile
Nov 20 2014
On Thursday, 20 November 2014 at 15:31:28 UTC, bearophile wrote:Kent:Thank you for your reply. But it still doesn't work.I am reading the book 《D Cookbook》 In Page 36,this code can't be complied: auto filtered = filter!((a) => Clock.currTime() - a.timeLastModified >> 14.days)(sorted);Perhaps: mySorted.filter!(a => Clock.currTime - a.timeLastModified > 14.days); Bye, bearophile
Nov 20 2014
On Thursday, 20 November 2014 at 15:33:37 UTC, Kent wrote:Are you sure you saw the important difference? There was a >> in the first post and it should be >. There's a few times throughout chapter one and two of the book where some symbols got messed up in the editing process and not fixed by the final draft. This looks like one of them.mySorted.filter!(a => Clock.currTime - a.timeLastModified > 14.days);Thank you for your reply. But it still doesn't work.
Nov 20 2014
On Thursday, 20 November 2014 at 15:38:10 UTC, Adam D. Ruppe wrote:On Thursday, 20 November 2014 at 15:33:37 UTC, Kent wrote:I have notice the difference.Changed the ">>" to ">". void main(string[] argv) { import std.file, std.algorithm, std.datetime, std.range,std.stdio; DirEntry[] allFiles; foreach(DirEntry entry; dirEntries("E:/TDDOWNLOAD", SpanMode.depth)) allFiles ~= entry; auto sorted = sort!((a,b) => a.size > b.size)(allFiles); auto filtered = filter!(a => Clock.currTime() - a.timeLastModified > 14.days)(sorted); foreach(file; filtered.take!(10)) writeln(fiel.name); }Are you sure you saw the important difference? There was a >> in the first post and it should be >. There's a few times throughout chapter one and two of the book where some symbols got messed up in the editing process and not fixed by the final draft. This looks like one of them.mySorted.filter!(a => Clock.currTime - a.timeLastModified > 14.days);Thank you for your reply. But it still doesn't work.
Nov 20 2014
On Thursday, 20 November 2014 at 15:45:55 UTC, Kent wrote:foreach(file; filtered.take!(10))Oh, there shouldn't be a ! there either. Should be take(10), not take!(10). That's my mistake too...writeln(fiel.name);also file is misspelled.
Nov 20 2014
On Thursday, 20 November 2014 at 15:56:34 UTC, Adam D. Ruppe wrote:On Thursday, 20 November 2014 at 15:45:55 UTC, Kent wrote:Thank you very much for help me. I notice another problem: foreach(file; filtered.take!(10)){...} This line has errors.I read the stdlib reference, and change the line to: foreach(file; take(filtered, 10)){...} It becomes right. Thank you again.foreach(file; filtered.take!(10))Oh, there shouldn't be a ! there either. Should be take(10), not take!(10). That's my mistake too...writeln(fiel.name);also file is misspelled.
Nov 20 2014