Accessing a Specific Element in a Tuple

后端 未结 7 2171
南笙
南笙 2020-12-11 00:17

Haskell-newbie reporting in. Question is as follows: In Haskell, we have fst and snd that return the first and the second elements of a 2-tuple. Wh

7条回答
  •  忘掉有多难
    2020-12-11 00:52

    The question of an approach to doing this using template haskell was previously addressed here.

    An example of its usage:

    > $(sel 2 3) ('a','b','c')
    'b'
    > $(sel 3 4) ('a','b','c','d')
    'c'
    

    From here.

提交回复
热议问题