Speaking of which, what's wrong with the standard library function for
producing permutations? They're not produced in the order you want them in?

On Mon, Oct 27, 2014 at 12:26 PM, Stefan Karpinski <[email protected]>
wrote:

> I tried sort!(sub(p,fp:length(p))) but it any faster. I suspect that if
> you want to keep with the general shape of this code, it gets kind of
> verbose. You can probably do something that's different and much more
> efficient though – similar to what the standard library does.
>
> On Mon, Oct 27, 2014 at 12:22 PM, Ivar Nesje <[email protected]> wrote:
>
>>
>>> P.S. I have tried using in-place
>>>    sort!(p[fp:end])
>>> rather than
>>>    p[fp:end] = sort(p[fp:end])
>>> but it does not do what I expected.
>>>
>>
>> The thing here is quite subtle, but the problem is that currently
>> p[fp:end] returns a copy, rather than a reference. This will change in 0.4,
>> but there are still lots of discussion needed on some of the subtleties, so
>> that we don't do too many iterations before getting it right.
>>
>> I think you can get it now, by writing:
>>
>> sort!(sub(p,fp:length(p)))
>>
>> Regards Ivar
>>
>
>

Reply via email to