HP Forums
is_cycle? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: is_cycle? (/thread-11090.html)



is_cycle? - John Keith - 07-19-2018 01:32 PM

Does anyone know how this function is supposed to work? it is one of the CAS functions introduced in the latest update. The release notes do not explain it and Help just says it tests whether a permutation is a cycle. The functions cycle2perm and permu2cycles work as described here but is_cycle seems to return 1 for any permutation whether cyclic or not.

TIA,
John


RE: is_cycle? - parisse - 07-19-2018 04:36 PM

is_cycle returns 0 if the list contains a negative value or if a value is not unique (by the way, I just realize that the algorithm for checking that should be improved, it is currently in O(n^2)).


RE: is_cycle? - John Keith - 07-19-2018 09:10 PM

I see. I was hoping it could test whether a given permutation was cyclic or not, but I realized that I could just check the size of the list returned by permu2cycles.