Hello,
To make a list of the letters at even-numbered position in Alphabet, I wrote these codes:
Select[Alphabet[], EvenQ[Flatten[Position[Alphabet[], #]]] &]
But it can't solve. May you tell me where I did wrong?
Thanks
Yes. It is a good idea.
Or more elementary
FromCharacterCode /@ Range[66, 90, 2] FromCharacterCode /@ Range[98, 122, 2]
Thanks a lot. I haven't seen it before.
crossposted: https://mathematica.stackexchange.com/questions/263639/list-letters-at-even-or-odd-numbered-positions-in-alphabet
Thanks. I know now.
You can read about the Part syntax here: http://reference.wolfram.com/language/ref/Part.html
Summary:
someList[[2]] (*gives the second element of a list*) someList[[2;;10]] (*gives elements 2 through 10*) someList[[2 ;;]] (*gives elements 2 through the end of the list*) someList[[2 ;; 10 ;; 3]] (*gives elements 2 through 10 in steps of 3*) someList[[2 ;; ;; 3]] (*gives elements 2 through the end in steps of 3*)
Here are some other options:
Partition[Alphabet[], 2][[All, 2]] SequenceSplit[Alphabet[], {_, b_} :> b] Downsample[Alphabet[], 2, 2]
[2 ;; ;; 2]
Thanks for your reply. May you tell me where can I learn this syntax. I can't understand it.
Here's one approach:
Alphabet[][[2 ;; ;; 2]]
That's using Part, with starting position 2, no end position, and step size of 2.