TransWikia.com

How can I get an element of a sequence?

Mathematica Asked on February 17, 2021

How can I get an element of a sequence?
For example Sequence[a,b,c,d]
How can get c?

One Answer

seq = Sequence[a, b, c, d]
Sequence[a, b, c, d]

You can use a composition of Part ([[...]]) and List as suggested by J.M.'sennui:

{seq}[[3]]
c
(Part[#, 3] & @* List)[seq]
c

Alternatively, you can use Slot[3] (that is, #3):

#3 & @ seq
c
Slot[3] &[seq]
c

Correct answer by kglr on February 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP