Thierry wrote:
What's the use of this?
Code: Select all
function x y
return not matchText(binaryEncode("A" & y," "),"^ ?$|^( +?)\1+$")
end x
Ok,here is the answer, only renaming the function:
Code: Select all
function isAprimeNumber aNumber
return not matchText(binaryEncode("A" & aNumber," "),"^ ?$|^( +?)\1+$")
end isAprimeNumber
Of course, it's just a one-liner script for fun, playing with LiveCode.
If you want to do this in a more traditonal and efficient way,
here is a working code:
Credits to Abigail,the prolific Perl hacker Abigail
who is famous for posting enigmatic but ingenious one-liner scripts
in her signatures on newsgroups.
Here’s one that blew my mind, from comp.lang.perl.misc:
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/' [number]
and if you're curious about how this works:
http://neilk.net/blog/2000/06/01/abigai ... e-numbers/
Regards,
Thierry