Re: Lazy caching map()?

2018-03-19 Thread Graham Fawcett via Digitalmars-d
On Monday, 19 March 2018 at 16:47:16 UTC, Graham Fawcett wrote: On Friday, 9 March 2018 at 19:41:46 UTC, H. S. Teoh wrote: Today I found myself needing a lazy, caching version of map() on an array. More precisely, given an array `T[] src` of source data and a function func(T) that's pretty

Re: Lazy caching map()?

2018-03-19 Thread Graham Fawcett via Digitalmars-d
On Friday, 9 March 2018 at 19:41:46 UTC, H. S. Teoh wrote: Today I found myself needing a lazy, caching version of map() on an array. More precisely, given an array `T[] src` of source data and a function func(T) that's pretty expensive to compute, return an object `result` such that: [...]

Re: Lazy caching map | Mir version

2018-03-18 Thread 9il via Digitalmars-d
On Friday, 9 March 2018 at 19:41:46 UTC, H. S. Teoh wrote: Today I found myself needing a lazy, caching version of map() on an array. More precisely, given an array `T[] src` of source data and a function func(T) that's pretty expensive to compute, return an object `result` such that: -

Re: Lazy caching map()?

2018-03-13 Thread H. S. Teoh via Digitalmars-d
On Wed, Mar 14, 2018 at 12:12:44AM +, aliak via Digitalmars-d wrote: [...] > Btw, I just saw someone posted a link to an old forum post of yours: > https://forum.dlang.org/post/mailman.2562.1403196857.2907.digitalmar...@puremagic.com > > Mind if I add that (or a version of it) to a library

Re: Lazy caching map()?

2018-03-13 Thread aliak via Digitalmars-d
On Tuesday, 13 March 2018 at 17:24:35 UTC, H. S. Teoh wrote: Very nice. Using memoize did occur to me, but I needed an array interface to it. Didn't think of using memoize with map, for some reason. Thanks for the idea! However, looking at the implementation of memoize, it seems that it's

Re: Lazy caching map()?

2018-03-13 Thread H. S. Teoh via Digitalmars-d
On Sat, Mar 10, 2018 at 08:54:16PM +, aliak via Digitalmars-d wrote: > On Friday, 9 March 2018 at 19:41:46 UTC, H. S. Teoh wrote: > > [...] More precisely, given an array `T[] src` of source data and a > > function func(T) that's pretty expensive to compute, return an > > object `result` such

Re: Lazy caching map()?

2018-03-10 Thread aliak via Digitalmars-d
On Friday, 9 March 2018 at 19:41:46 UTC, H. S. Teoh wrote: Today I found myself needing a lazy, caching version of map() on an array. More precisely, given an array `T[] src` of source data and a function func(T) that's pretty expensive to compute, return an object `result` such that: -

Re: Lazy caching map()?

2018-03-09 Thread H. S. Teoh via Digitalmars-d
On Fri, Mar 09, 2018 at 12:47:14PM -0700, Jonathan M Davis via Digitalmars-d wrote: > On Friday, March 09, 2018 11:41:46 H. S. Teoh via Digitalmars-d wrote: > > [...] More precisely, given an array `T[] src` of source data and a > > function func(T) that's pretty expensive to compute, return an

Re: Lazy caching map()?

2018-03-09 Thread Jonathan M Davis via Digitalmars-d
On Friday, March 09, 2018 11:41:46 H. S. Teoh via Digitalmars-d wrote: > Today I found myself needing a lazy, caching version of map() on an > array. More precisely, given an array `T[] src` of source data and a > function func(T) that's pretty expensive to compute, return an object > `result`

Lazy caching map()?

2018-03-09 Thread H. S. Teoh via Digitalmars-d
Today I found myself needing a lazy, caching version of map() on an array. More precisely, given an array `T[] src` of source data and a function func(T) that's pretty expensive to compute, return an object `result` such that: - result[i] == func(src[i]), for 0 ≤ i < src.length. - If result[j]