Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Triple Accessing Element

Tags:

haskell

If in Haskell I had a tuple:

x = (1, 2)

I could use fst x to retrieve 1 and snd x to retrieve 2

I was wondering, if I had a triple:

y = (1, 2, 3)

is there a similar function I could use?

like image 811
MrD Avatar asked Dec 07 '13 23:12

MrD


1 Answers

You need to write your own extractor functions:

extractFirst :: (a, b, c) -> a
extractFirst (a,_,_) = a

The fst and snd functions are only applicable for a tuple i.e (a, b)

like image 127
Sibi Avatar answered Oct 05 '22 11:10

Sibi