To make a list of the letters at even-numbered position in Alphabet, I wrote this code:
Select[Alphabet[], EvenQ[Flatten[Position[Alphabet[], #]]] &]
But it does not work. Where did I go wrong?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityMuch simpler solution:
Alphabet[][[1 ;; All ;; 2]]
Alphabet[][[2 ;; All ;; 2]]
Alphabet[][[1 ;; ;; 2]]
is equivalent and slightly shorter.
$\endgroup$
Feb 16, 2022 at 19:20
I've used Range to determine the sequence.
Alphabet[][[Range[1, 26, 2]]]
for odd positions,
for even positions Alphabet[][[Range[2, 26, 2]]]
Flatten[Position[Alphabet[], "a"]]
gets you{1}
and not1
. $\endgroup${False}
and what you need is just plainFalse
. $\endgroup$Select[Alphabet[], EvenQ[Flatten[Position[Alphabet[], #]]][[1]] &]
. $\endgroup$