How to sort byCodeUnit.permutations.filter(...)

Uknown sireeshkodali1 at gmail.com
Tue Jun 12 15:16:25 UTC 2018


On Tuesday, 12 June 2018 at 14:21:48 UTC, Adam D. Ruppe wrote:
> On Monday, 11 June 2018 at 04:39:54 UTC, Uknown wrote:
>> Why are the strings getting modified?
>
> I'm guessing it reuses a buffer as it iterates.
>
>> "123".byCodeUnit.permutations.writeln;//[123, 213, 312, 132, 
>> 231, 321]
>
> [...]
>
> 	"1234567".byCodeUnit
> 		.permutations
>                 .map!(to!int)
> 		.filter!(a => primes.canFind(a))
>                 .maxElement
>
>
> that should do it too.

I solved the problem by piping the output to `sort`, but your 
workaround is useful. I'll submit a bug report on this ASAP. 
Thanks for your help!


More information about the Digitalmars-d-learn mailing list