Get the second element in a list of tuples?

Hi,
I have a data record that contains a list of tuples that hold different types.
predictions : [( Text, Numeric 2)]

I am trying to take the Numeric 2 value and mulitpy it with another Numeric 2 value from a different record.

payoutRate = eventPayload.eventRecord.predictions!!1
let payoutAmt  = betPayload.betSlip.wager * payoutRate

How can I skip over the first part of the tuple (Text) and get the number?

The snd function returns the second item in a tuple (docs).

The following should do what you are looking for.

let payoutAmt  = betPayload.betSlip.wager * (snd payoutRate)

One feature of the docs.daml.com that I like particularly is looking for a function by signature: if you type (a, b) -> b in the search bar, you will find what you are looking for. In my example a and b are generic types, but searching by signature is smart enough to deal with generic types, so looking for (Text, Numeric 2) -> Numeric 2 will still return the answer you are looking for (even though snd is more generic than that).

1 Like