Wikipedia:Reference desk/Archives/Computing/2014 May 8

Computing desk
< May 7 << Apr | May | Jun >> May 9 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


May 8 edit

Uneven text size on Android browsers edit

So, I have a Lenovo A369i, and while I managed to turn this text reflow option off on the default browser, and turning on Text Wrap in Opera did the trick, for some reason I couldn't find the equivalent setting in Firefox. Blake Gripling (talk) 07:42, 8 May 2014 (UTC)[reply]

Python edit

print(*[hi_stem(word) for word in line.split()])

What does the * in front of "[hi_stem..." signify? This is written in Python 3.1, and I use 2.7 and I can't get to make it work in my version. Any help is much appreciated. La Alquimista 07:46, 8 May 2014 (UTC)[reply]

The * unpacks the arguments. It doesn't work in Python 2 because print isn't a function. It should work if you add from __future__ import print_function to the top of the file. -- BenRG (talk) 07:55, 8 May 2014 (UTC)[reply]
So you'll need to glue the strings together somehow; there ought to be a function for that but I haven't found it yet. —Tamfang (talk) 04:59, 10 May 2014 (UTC)[reply]
If you just want to join a list (or tuple, or other iterable) of strings together, you use "".join(["this", "is", "a", "list"]) and if you want a separator between them (e.g. a space) " ".join(["this", "is", "a", "list"])       -- Finlay McWalterTalk 09:27, 10 May 2014 (UTC)[reply]

Discarding prime powers in PARI edit

I've written the following PARI code

N=10^9; for(n=2, N, if(Mod(binomial(2*n-1, n-1), n) == 1 && !isprime(n), print1(n, ", ")));

The problem is that this also reports all prime powers, which I don't want. Is there an easy way to tell PARI to not report prime powers? -- Toshio Yamaguchi 17:13, 8 May 2014 (UTC)[reply]

!(ispower(n,,&r) & isprime(r)) PrimeHunter (talk) 01:21, 11 May 2014 (UTC)[reply]
@PrimeHunter: I adjusted my code.
N=10^9; for(n=2, N, if(Mod(binomial(2*n-1, n-1), n)==1 && !ispower(n) && !isprime(n), print1(n, ", ")));
appears to work. Now I only have to adjust the code so that I can use the function from the script I am using (a script for faster computation of binomial coefficients modulo some integer). But I could add this code to the corresponding sequence in the OEIS. Thanks. -- Toshio Yamaguchi 21:05, 11 May 2014 (UTC)[reply]
Btw what is the reason you are using two different variables n and r in the code? I tested and the code I posted above correctly finds the first expected solution. -- Toshio Yamaguchi 21:10, 11 May 2014 (UTC)[reply]
?ispower
ispower(x,{k},{&n}): true (1) if x is a k-th power, false (0) if not. If n is given and a k-th root was computed in the process, put that in n. If k is omitted, return the maximal k >= 2 such that x = n^k is a perfect power, or 0 if no such k exist.
You asked to eliminate prime powers so my code does that by setting r to the root and testing whether it's prime. Your own code also eliminates powers of composites, for example n=36 with r=6. I haven't examined whether that is relevant to your problem. PrimeHunter (talk) 21:20, 11 May 2014 (UTC)[reply]
I am interested in the PARI code for finding the terms of A228562 and have added that code. Thanks for the help. I wasn't aware if ispower. -- Toshio Yamaguchi 21:28, 11 May 2014 (UTC)[reply]

Mobile phone text message screenshots edit

OK, I'll have to ask. I have seen various screenshots of mobile phone text message conversations on the Internet. They all follow the same graphical pattern, and are pixel-for-pixel accurate. How are these made? Can people these days take screenshots of their mobile phone screens and upload them to the Internet, or is there some sort of fancy on-line tool that creates graphical images of text message transcripts? Or do people really type all the messages by hand to an on-line tool, which I rather doubt? JIP | Talk 17:54, 8 May 2014 (UTC)[reply]

You didn't say what phones you're referring to. On recent (past few years, not sure precisely when it was added) versions of iOS and Android, there are built in ways to take screenshots. Android has also supported taking screenshots on the computer via ADB probably since version 2 or earlier. I suspect Windows Phones also have some way to take screenshots or really any decent smartphone OS. And any decent smartphone can upload local media such as photographs taken via the phone or screenshots to sites which support them via the browser or other methods. (I'm pretty sure even iOS which severely restricts what apps can access allows this.) Nil Einne (talk) 18:46, 8 May 2014 (UTC)[reply]
A lot of them will be iOS screenshots taken on iPhones. Those will be pretty nearly pixel-perfect to each-other because they're all running exactly the same software.
There's also websites (example) that will fake it for you. (ie:for comedy reasons)
APL (talk) 20:25, 8 May 2014 (UTC)[reply]