Message Boards Message Boards

0
|
2841 Views
|
9 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Make a list of the letters at even-numbered position in Alphabet.

Posted 2 years ago

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

POSTED BY: Zhenyu Zeng
9 Replies

Or more elementary

FromCharacterCode /@ Range[66, 90, 2]
FromCharacterCode /@ Range[98, 122, 2]
POSTED BY: Hans Dolhaine
Posted 1 year ago

Yes. It is a good idea.

POSTED BY: Zhenyu Zeng
Posted 2 years ago
Posted 1 year ago

Thanks a lot. I haven't seen it before.

POSTED BY: Zhenyu Zeng
Posted 2 years ago

Here are some other options:

Partition[Alphabet[], 2][[All, 2]]

SequenceSplit[Alphabet[], {_, b_} :> b]

Downsample[Alphabet[], 2, 2]
POSTED BY: Eric Rimbey
Posted 2 years ago

Here's one approach:

Alphabet[][[2 ;; ;; 2]]

That's using Part, with starting position 2, no end position, and step size of 2.

POSTED BY: Eric Rimbey
Posted 2 years ago
[2 ;; ;; 2]

Thanks for your reply. May you tell me where can I learn this syntax. I can't understand it.

POSTED BY: Zhenyu Zeng
Posted 2 years ago

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*)
POSTED BY: Eric Rimbey
Posted 2 years ago

Thanks. I know now.

POSTED BY: Zhenyu Zeng
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract