This yields exactly what I want, but to the price of a high cost in memory and processing. The problem is with the .. operator. The number of elements generated before the grep by the .. operator is 361,173. After the grep you are left with only 774 "useful" strings. And if you wanted to get all strings up to 5 letters you would then have to deal with nearly 10,000,000 elements. And things only get worse.my @strings = (grep /[acgmt]{2}/, ('aa' .. 'tt'), grep /[acgmt]{3}/, ('aaa' .. 'ttt'), grep /[acgmt]{4}/, ('aaaa' .. 'tttt'));
This would causes a lazy list to be passed to the filter function grep, saving us from allocating the entire letter combinations array in memory. While this might not be the greatest example ever, I think it's simple enough to illustrate the possibilities.my @strings = (grep /[acgmt]{2}/, lazy ('aa' .. 'tt'), grep /[acgmt]{3}/, lazy ('aaa' .. 'ttt'), grep /[acgmt]{4}/, lazy ('aaaa' .. 'tttt'));
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Let's get lazy
by japhy (Canon) on Aug 28, 2001 at 20:47 UTC | |
|
Re: Let's get lazy
by Masem (Monsignor) on Aug 28, 2001 at 20:37 UTC | |
|
(MeowChow) Re: Let's get lazy
by MeowChow (Vicar) on Aug 28, 2001 at 22:10 UTC | |
|
Re: Let's get lazy
by dga (Hermit) on Aug 28, 2001 at 23:05 UTC | |
|
Re: Let's get lazy
by runrig (Abbot) on Nov 02, 2001 at 04:31 UTC | |
by tilly (Archbishop) on Nov 03, 2001 at 02:50 UTC | |
by tilly (Archbishop) on Nov 02, 2001 at 17:07 UTC | |
|
Re: Let's get lazy
by beretboy (Chaplain) on Nov 02, 2001 at 03:36 UTC | |
by blakem (Monsignor) on Nov 02, 2001 at 04:26 UTC |