Questions tagged [enumerate]

Related to functions or methods that return enumerations or enumerated-types. These can be objects, data types or data structures in which each of the items of a set has a one-to-one correspondence with a set of ordered numbers. An example is the `enumerate()` built-in function in Python.

Related to functions or methods that return enumerations or enumerated-types. These can be objects, data types or data structures in which each of the items of a set has a one-to-one correspondence with a set of ordered numbers. An example is the enumerate() built-in function in Python.

In Python, the function enumerate(sequence, start=0) sequence must be an object which supports iteration. enumerate() returns an enumerate object which consists of tuples containing a count (from start) and the values obtained from iterating over sequence (from the Python Standard Library official documentation)

975 questions
7
votes
4 answers

How to list the file paths of all buffers open in Vim?

Is there a way to list all open buffers in Vim? I’d like to view the full file path to every open buffer and save the list to an external file, or yank it for pasting into another text document. Solution This was a very hard contest! All three of…
Jonathan Beebe
  • 5,241
  • 3
  • 36
  • 42
7
votes
2 answers

python - increase efficiency of large-file search by readlines(size)

I am new to Python and I am currently using Python 2. I have some source files that each consists of a huge amount of data (approx. 19 million lines). It looks like the following: apple \t N \t apple n&apos garden \t N \t garden b\ta\md…
7
votes
3 answers

Iterating along a Dictionary in Swift 3

I am trying to iterate along a Dictionary in order to prune unconfirmed entries. The Swift 3 translation of the following Objective-C code does not work: [[self sharingDictionary] enumerateKeysAndObjectsUsingBlock: ^(id key, id obj, BOOL *stop) { …
Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75
7
votes
4 answers

How to iterate initialized enumerated types with Delphi 6 and avoid the "out of bounds" error?

I am using Delphi 6 Professional. I am interfacing with a DLL libraty that declares an enumberated type as follows: TExtDllEnum = (ENUM1 = $0, ENUM2 = $1, ENUM3 = $2, ENUM4 = $4, ENUM5 = $8, ENUM6 = $10); As you can see the initialized values are…
Robert Oschler
  • 14,153
  • 18
  • 94
  • 227
7
votes
1 answer

\table in \enumerate environment in latex

I want to insert a \table in \enumerate environment and I have something like this: \begin{enumerate} \item Item 1. \item Item 2. \item \begin{table}[htbp] \textbf{\caption{Table1 Caption}} \centering …
hellfragger
  • 143
  • 1
  • 4
  • 12
7
votes
2 answers

Iterating through a character/string array in LaTeX

This is a continuation of my question posted earlier (Outputting character string elements neatly in Sweave in R). I have an array of strings, and am trying to output each element into LaTeX. I am able to achieve that using the following…
user1830307
7
votes
2 answers

What is the implementation detail for enumerate?

Python has enumerate() to iterate over objects with an index.I doubt that interpreters create a lot of int objects for the sole purpose of keeping track of where things are. The PEP page says the following, but I do not really understand what is…
Forethinker
  • 3,548
  • 4
  • 27
  • 48
7
votes
6 answers

Python: finding distances between list fields

Hi I need to calculate distances between every numbers pair in list, including the distance between the last and the first (it's a circle). Naively i can do something like that: l = [10,-12,350] ret = [] for i in range(len(l)-1): …
mclafee
  • 1,406
  • 3
  • 18
  • 25
6
votes
1 answer

How do I enumerate on a vector of Strings?

let output_sorted: Vec = four_digit_ouput .iter() .map(|tok| tok.chars().sorted().collect::()) .collect(); let output = 0; for (idx, digit) in output_sorted.enumerate() { I get this error when I try to do an…
Lacrosse343
  • 491
  • 1
  • 3
  • 18
6
votes
1 answer

Nim enumerate function like Python

Learning Nim and I like it resemblence of Python (but fast). In Python I can do this: item_index = [(idx, itm) for idx, itm in enumerate(row)] Im looking for a way to enumerate a Nim sequence so I would write this: item_index = lc[(idx, itm) |…
Peheje
  • 12,542
  • 1
  • 21
  • 30
6
votes
1 answer

Foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'

I'm trying to figure out how to access values in an object through an API, but am having no luck. There is some documentation, but not a lot. I'm able to access some information, but what I'm looking for exists in a keyword field in a database that…
Tom D
  • 351
  • 1
  • 4
  • 13
6
votes
3 answers

Enumerate sentences in python

I have a tuple of strings that consists of two sentences a = ('What', 'happened', 'then', '?', 'What', 'would', 'you', 'like', 'to', 'drink','?') I tried this for i,j in enumerate(a): print i,j which gives 0 What 1 happened 2 then 3 ? 4 What 5…
user3635159
  • 157
  • 2
  • 11
6
votes
2 answers

Differences between enumerate(fileinput.input(file)) and enumerate(file)

I'm looking for some help with my code which is rigth below : for file in file_name : if os.path.isfile(file): for line_number, line in enumerate(fileinput.input(file, inplace=1)): print file os.system("pause") …
flor14n
  • 61
  • 3
6
votes
3 answers

What happens with Directory.EnumerateFiles if directory content changes during iteration?

I've read discussions about difference between Directory.EnumerateFiles and Directory.GetFiles. I understand that internally they both use System.IO.FileSystemEnumerableFactory.CreateFileNameIterator() The difference is that EnumerateFiles might use…
Harald Coppoolse
  • 28,834
  • 7
  • 67
  • 116
6
votes
2 answers

Ruby get nth item from massive range

Suppose I have this range: ("aaaaa".."zzzzz") How would I get the Nth item from the range without generating the entire thing before hand/each time?
Bub Bradlee
  • 2,905
  • 2
  • 19
  • 15