Re: Chaining std.algorithm

2013-12-19 Thread Ali Çehreli
On 12/19/2013 03:45 AM, Jakob Ovrum wrote: On Monday, 16 December 2013 at 06:07:00 UTC, Ali Çehreli wrote: .find!(data => data.digit.equal([ a ])) Use `std.range.only(a)` instead of `[a]` to avoid allocating GC memory. Thanks. That is the second time I see 'only'. Hopefully, it will stick t

Re: Chaining std.algorithm

2013-12-19 Thread Jakob Ovrum
On Monday, 16 December 2013 at 06:07:00 UTC, Ali Çehreli wrote: .find!(data => data.digit.equal([ a ])) Use `std.range.only(a)` instead of `[a]` to avoid allocating GC memory.

Re: Chaining std.algorithm

2013-12-16 Thread monarch_dodra
On Monday, 16 December 2013 at 04:45:40 UTC, John Carter wrote: When I try use find in map!"find!""" dmd whinges like crazy at me. First of all, you'd need to use: map!`find!""` , since you are nesting strings. As you wrote it, it looks like: map!"find!" ~ "" See the difference ? Second, unf

Re: Chaining std.algorithm

2013-12-15 Thread H. S. Teoh
On Mon, Dec 16, 2013 at 05:42:10PM +1300, John Carter wrote: [...] > Now I'm sure I can use std.algorithm map to convert say a string of > characters "IVXLCDM" into an array [1,5,10,50,100,500,1000] > > but somehow D template instantiation syntax is flumoxing me. > > When I try use find in map!"f

Re: Chaining std.algorithm

2013-12-15 Thread Ali Çehreli
On 12/15/2013 09:46 PM, Ali Çehreli wrote: > On 12/15/2013 08:42 PM, John Carter wrote: > > Now I'm sure I can use std.algorithm map to convert say a string of > > characters "IVXLCDM" into an array [1,5,10,50,100,500,1000] The following program works. Note that 'result' is a lazy range. You

Re: Chaining std.algorithm

2013-12-15 Thread Ali Çehreli
On 12/15/2013 08:42 PM, John Carter wrote: > So I have an array of data... > struct romanSystemData { > string digit; > uint value; > ulong regionIndex; > ulong previous; > }; > > immutable romanSystemData romanSystem[] = [ > {"" ,0, 0, 0},//0 > {"I",1, 0, 0}

Re: Chaining std.algorithm functions

2012-04-12 Thread H. S. Teoh
On Thu, Apr 12, 2012 at 07:00:35PM +0200, DH wrote: > Hi. I was wondering why the following works: > > filter!(a => a % 2 == 0)(map!(a => a + 1)([1,2,3,4,5])) > > but the following does not: > > [1,2,3,4,5] > .map!(a => a + 1)() > .filter!(a => a % 2 == 0)() > > ...givin

Re: Chaining std.algorithm functions

2012-04-12 Thread Brad Anderson
On Thursday, 12 April 2012 at 17:00:37 UTC, DH wrote: Hi. I was wondering why the following works: filter!(a => a % 2 == 0)(map!(a => a + 1)([1,2,3,4,5])) but the following does not: [1,2,3,4,5] .map!(a => a + 1)() .filter!(a => a % 2 == 0)() ...giving me the error `Er