tuples Questions

3

Solved

Is there a way to get one value from a tuple in Python using expressions? def tup(): return (3, "hello") i = 5 + tup() # I want to add just the three I know I can do this: (j, _) = tup() i = ...
Larousse asked 28/6, 2010 at 20:55

4

Solved

I know lambda doesn't have a return expression. Normally def one_return(a): #logic is here c = a + 1 return c can be written: lambda a : a + 1 How about write this one in a lambda function...
Bashemath asked 21/5, 2013 at 15:39

5

Solved

I have a problem with the type of one of my column in a pandas dataframe. Basically the column is saved in a csv file as a string, and I wanna use it as a tuple to be able to convert it in a list o...
Gabar asked 10/5, 2018 at 17:23

3

Solved

I would have thought that a list of tuples could easily be flattened: scala> val p = "abcde".toList p: List[Char] = List(a, b, c, d, e) scala> val q = "pqrst".toList q: List[Char] = List(p,...
Tusker asked 11/5, 2016 at 7:22

5

Solved

I have a list of tuples like this: [('foo','bar'),('foo1','bar1'),('foofoo','barbar')] What is the fastest way in python (running on a very low cpu/ram machine) to swap values like this... [('bar'...
Subfamily asked 14/11, 2012 at 18:19

5

Swift Tuple index using a variable as the index? Anyone know if it is possible to use a variable as the index for a Swift tuple index. I wish to select and item from a tuple using a random number. ...
Swaraj asked 28/6, 2016 at 11:29

2

Solved

I've two IEnumerable<double>s, that I want to build an IEnumerable of Tuple<int, double, double> from. Item1 of the Tuple should be the index of the item, Item2 the value in index-th pl...
Gabriello asked 29/11, 2011 at 13:42

5

Solved

I'm trying to write a haskell function that takes in two lists of integers and generates a list with elements that have been taken alternatingly from the two lists. I have the function: blend xs...
Buber asked 12/12, 2011 at 6:20

2

Solved

I have: val DF1 = sparkSession.sql("select col1,col2,col3 from table"); val tupleList = DF1.select("col1","col2").rdd.map(r => (r(0),r(1))).collect() tupleList.foreach(x=> x.productIterator...
Predominate asked 24/1, 2017 at 14:38

3

Solved

type a = [1,2,3] type Invert<T extends any[] & {'0': any}> = ??? type b = Invert<a> // should yield [3,2,1] I am stucked to figure out the definition of Invert type of a tuple, al...
Triplenerved asked 9/1, 2020 at 6:47

5

Solved

Suppose I have a function like: def myfun(a, b, c): return (a * 2, b + c, c + b) Given a tuple some_tuple = (1, "foo", "bar"), how would I use some_tuple to call myfun? This s...
Ultun asked 3/1, 2010 at 2:22

5

Solved

Here's how I'm currently converting a list of tuples to dictionary in Python: l = [('a',1),('b',2)] h = {} [h.update({k:v}) for k,v in l] > [None, None] h > {'a': 1, 'b': 2} Is there...
Albuminate asked 29/6, 2011 at 14:35

1

Just curious why I can't do this: let myFn (data : obj) = match data with | :? (string * string) as (s1, s2) -> sprintf "(%s, %s)" s1 s2 |> Some | :? (string * string * int) as (...
Freed asked 9/11, 2020 at 7:31

2

Solved

I'd like to define a concept which just tuples with values of a specific type can satisfy. Let's say for simplicity I just want to accept tuples just holding elements of a numeric type. How would I...
Bitch asked 5/11, 2020 at 9:14

4

Solved

I can't pass a tuple as a method parameter: scala> val c:Stream[(Int,Int,Int)]= Stream.iterate((1, 0, 1))((a:Int,b:Int,c:Int) => (b,c,a+b)) <console>:11: error: type mismatch; found :...
Gastroenterology asked 3/7, 2015 at 12:52

3

Solved

I create my Tuple and add it to a combo box: comboBox1.Items.Add(new Tuple<string, string>(service, method)); Now I wish to cast the item as a Tuple, but this does not work: Tuple<stri...
Affiliation asked 30/1, 2013 at 13:44

3

Trying to make a list tuple of two Integers and after that adding something in it. Then comparing if x,y is one of the tuples in list tuple. List<Tuple<int, int>> monsterPositions; I...
Illegitimacy asked 24/10, 2017 at 6:57

6

Solved

I have a list of tuples, the list can vary in length between ~8 - 1000 depending on the length of the tuples. Each tuple in the list is unique. A tuple is of length N where each entry is a generic ...
Historicity asked 29/9, 2020 at 15:23

1

Solved

I want to specify how the rest of the array should look without knowing how many values the array will have. How can I achieve something like this? (playground version here): type numStrArr = [num...
Disforest asked 5/7, 2017 at 19:30

2

I'm new to Haskell, I have a question regarding tuples. Is there not a way to traverse a tuple? I understand that traversal is very easy with lists but if the input is given as a tuple is there not...
Indraft asked 13/10, 2020 at 13:29

1

Solved

I was curious to see whether sorting a vector <vector<int>> would be slower than sorting a vector <array <int, 3>>. The dimensions of the vector is 1000000 by 3, and below i...
Ground asked 6/10, 2020 at 19:1

4

Solved

I usually create custom structs when grouping values of different types together. This is usually fine, and I personally find the named member access easier to read, but I wanted to create a more g...
Acuate asked 8/7, 2019 at 15:9

9

Solved

Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements?
Abortionist asked 16/9, 2008 at 1:43

3

Solved

I'm trying to deconstruct a tuple inside a Linq expression // somewhere inside another method var result = from word in words let (original, translation) = Convert(word) select original Here is ...
Kruse asked 30/11, 2016 at 22:45

5

Solved

Is it possible to simulate extended tuple unpacking in Python 2? Specifically, I have a for loop: for a, b, c in mylist: which works fine when mylist is a list of tuples of size three. I want t...
Ethanol asked 17/3, 2011 at 1:5

© 2022 - 2024 — McMap. All rights reserved.