I am parsing RSS feeds with the format as specified here: http://www.feedparser.org/docs/date-parsing.html
date tuple (2009, 3, 23, 13, 6, 34, 0, 82, 0)
I am a bit stumped at how to get this into the MySQL datetime format (Y-m-d H:M:S)?
...
I want to be able to implicitly convert Tuples of numbers (Ints and double) into a vector object.
Assuming a Vector class with a + method
case class Vector(x: Double, y:Double){
def + (v:Vector)= new Vector(x+v.x,y+v.y)
}
My goal is to have the following code work.
val vec = (1,2)+(.5,.3) // vec == Vector(1.5,2.3)
I can get it...
Please explain what is meant by tuples in sql?Thanks..
...
What is the nicest way of splitting this:
tuple = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
into this:
tuples = [('a', 'b'), ('c', 'd'), ('e', 'f'), ('g', 'h')]
Assuming that the input always has an even number of values.
...
Why does nobody seem to use tuples in C++, either the Boost Tuple Library or the standard library for TR1? I have read a lot of C++ code, and very rarely do I see the use of tuples, but I often see lots of places where tuples would solve many problems (usually returning multiple values from functions).
Tuples allow you to do all kinds o...
I'm learning F#. I started by looking over the F# samples from Microsoft.
I ran across this statement:
let line1,line2 =
use sr = System.IO.File.OpenText @"test.txt"
let line1 = sr.ReadLine()
let line2 = sr.ReadLine()
(line1,line2)
Can anyone explain this statement to me?
What type is being defined here? A functio...
Hi!
How do I get a tuple/list element given a condition in python?
This occurs pretty often and I am looking for a nice-few-lines-pythonic way of doing this.
here could be an example:
Consider a tuple containing 2D points coordinates like this:
points = [[x1, y1],[x2, y2],[x3, y3], ...]
And I would like to get the point that minimi...
I'd like to split a comma separated value into pairs:
>>> s = '0,1,2,3,4,5,6,7,8,9'
>>> pairs = # something pythonic
>>> pairs
[(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)]
What would # something pythonic look like?
How would you detect and handle a string with an odd set of numbers?
...
I have a similar question to this one but instead my tuple contains lists, as follows:
mytuple = (
["tomato", 3],
["say", 2],
["say", 5],
["I", 4],
["you", 1],
["tomato", 6],
)
What's the most efficient way of sorting this?
...
I am trying to make a Dictionary lookup table in C#. I need to resolve a 3-tuple of values to one string. I tried using arrays as keys, but that did not work, and I don't know what else to do. At this point I am considering making a Dictionary of Dictionaries of Dictionaries, but that would probably not be very pretty to look at, thou...
As the title says, what is the differences between vectors, sets, and tuples in programming?
...
I am kind of hitting a wall on this problem and I was wondering if some fresh brains could help me out.
I have a large list of four element tuples in the format:
(ID number, Type, Start Index, End Index)
Previously in the code, I have searched through thousands of blocks of text for two specific types of substrings. These tuples stor...
I have a tuple containing lists and more tuples. I need to convert it to nested lists with the same structure. For example, I want to convert (1,2,[3,(4,5)]) to [1,2,[3,[4,5]]].
How do I do this (in Python)?
...
I'm reading CJ Date's SQL and Relational Theory: How to Write Accurate SQL Code, and he makes the case that positional queries are bad for example, this INSERT:
INSERT INTO t VALUES (1, 2, 3)
Instead, you should use attribute-based queries like this:
INSERT INTO t (one, two, three) VALUES (1, 2, 3)
Now, I understand that the first...
What is the most pythonic way of adding the values of two or more tuples to produce a total for each 'column'?
Eg:
>>> a = (10, 20)
>>> b = (40, 50)
>>> c = (1, 3)
>>> ???
(51, 73)
I've so far considered the following:
def sumtuples(*tuples):
return (sum(v1 for v1,_ in tuples), sum(v2 for _,v2 in tuples))
>>> print sumtuples(a,...
I am fairly new to Objective-C and was wondering what the best way to manage collections of tuples was. In C I would use a 2D array or a struct.
Should I be creating objects to contain these tuples? It seems like overkill for just sorting lists or is there no real extra load generated by object initialisation?
...
I have a list of tuples, each containing a find/replace value that I would like to apply to a string. What would be the most efficient way to do so? I will be applying this iteratively, so performance is my biggest concern.
More concretely, what would the innards of processThis() look like?
x = 'find1, find2, find3'
y = [('find1', 'rep...
Is there a better way to do this in python, or rather: Is this a good way to do it?
x = ('a', 'b', 'c')
y = ('d', 'e', 'f')
z = ('g', 'e', 'i')
l = [x, y, z]
s = set([e for (_, e, _) in l])
I looks somewhat ugly but does what i need without writing a complex "get_unique_elements_from_tuple_list" function... ;)
edit: expected value ...
The problem is easy, I want to iterate over each element of the list and the next one in pairs (wrapping the last one with the first).
I've thought about two unpythonic ways of doing it:
def pairs(lst):
n = len(lst)
for i in range(n):
yield lst[i],lst[(i+1)%n]
and:
def pairs(lst):
return zip(lst,lst[1:]+[lst[0]])...
When writing the following code in scala
var m = Map((0,1) -> "a")
m += ((0,2), "b") // compilation error
I'm getting the error
type mismatch;
found : Int(0)
required: (Int, Int)
However the changing the syntax of the tuple from (X,Y) to (X -> Y) works
var m = Map((0,1) -> 'a)
m += ((0,2) -> 'b) // compiles file
Even though...