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
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
Here’s one approach:
Alphabet[][[2 ;; ;; 2]]
That’s using Part, with starting position 2, no end position, and step size of 2.
[2 ;; ;; 2]
Thanks for your reply. May you tell me where can I learn this syntax. I can’t understand it.
Here are some other options:
Partition[Alphabet[], 2][[All, 2]]
SequenceSplit[Alphabet[], {_, b_} :> b]
Downsample[Alphabet[], 2, 2]
You can read about the Part syntax here: Part: Get a specified piece of an expression—Wolfram Documentation
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*)
Thanks. I know now.
Thanks a lot. I haven’t seen it before.
Or more elementary
FromCharacterCode /@ Range[66, 90, 2]
FromCharacterCode /@ Range[98, 122, 2]
Yes. It is a good idea.