Tuples

Tuple in Python

Reading Time: 3 minutes In this blog, we are going to discuss the tuple data structure of python. A tuple is a collection which is immutable, we cannot change the elements of a tuple once it is assigned. It allows duplicate members i.e. (1, 1) is allowed. Any set mutiple comma-separated symbols written default to tuples. >>> x, y = 1, 2 Dictionaries have a method called items that Continue Reading

How to flatten nested tuples in scala

Reading Time: 2 minutes In a project which I’ve been working on, I encountered a situation to flatten a nested tuple but couldn’t come up with a way to do so, hence out of curiosity I started googling about it and came to the following conclusion. As for an example I had a structure something similar to the one mentioned below, though not identical: val structureToOperateOn = List(List(“a1″,”a2″,”a3”), List(“b1″,”b2″,”b3”) Continue Reading

Scala Nuggets: The Tasty Tuples

Reading Time: 2 minutes One of the interesting things that Scala has to offer is a concept called Tuples. It is a literal syntax of comma-separated list of items inside parenthesis. Something like (a1, a2, a3). These “groupings” are instantiated as scala.TupleN instances, where the N is the number of items in the tuple. The Scala API defines separate TupleN classes for N between 1 and 22, inclusive. (I Continue Reading

Knoldus Pune Careers - Hiring Freshers

Get a head start on your career at Knoldus. Join us!