Questions tagged [counter]

A Counter is a container(/bag/multiset/etc.) that keeps track of how many times equivalent values are added.

In Python:

A Counter is a dict subclass for counting hashable objects. It is an unordered collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any integer value including zero or negative counts. The Counter class is similar to bags or multisets in other languages.

http://docs.python.org/library/collections.html#collections.Counter


5262 questions
1
vote
3 answers

How do you do a simple counter in Javascript functional programming?

I am redoing my coding to better fit functional programming and I can not find a good solution to a simple counter without mutation. const countRows = (element) => (obj) => { var count = 0; Object.entries(obj).forEach(([key,value]) => { if…
Justin Gagnon
  • 193
  • 2
  • 10
1
vote
0 answers

Counter of previous matches

I have found a lot of material about counting a value in table, but my goal is little different and I havent found any source. This is my data ID_1 ID_2 Date RESULT 1 12 3 2011-12-21 0 2 …
Mirko Piccolo
  • 319
  • 1
  • 2
  • 12
1
vote
2 answers

bash counter that ignores characters

I have this code in bash. I wanted to ask, how can I change this code that for example when if gets to the word Aaa: ----> the output of the length of this word will be 3 and not 4 (I want it to ignore other chars and only count the…
Michelle
  • 41
  • 5
1
vote
2 answers

In Scheme language, how to assign a variable counter in an inner do-loop connected with the outer do-loop?

I want to read 10 case files in Ansys Fluent and for each case file there are 10 data files to be read. Ansys Fluent uses Scheme programming language. I have to managed to get some answers to individual problems in the code here (Evaluating a…
Emma
  • 149
  • 10
1
vote
1 answer

Counter Using Javascript, HTML & CSS Not Working

Can anyone help me to get this (https://jsfiddle.net/hmatrix/v3jncqac/) code to work? Inentention: I want to create a counter that increases in increments. My HTML:
1
vote
5 answers

Haskell: how to keep count

I'm walking a directory recursively, in a conventional way. This is a working prototype: traverseFlatDst :: FilePath -> Int -> Int -> FilePath -> IO () traverseFlatDst dstRoot total totw srcDir = do (dirs, files) <- listDir srcDir mapM_ (\file…
Alexey Orlov
  • 2,412
  • 3
  • 27
  • 46
1
vote
2 answers

Tracing instantiation in a base class

Currently I trace number of instances of a base class this way: private static int _instanceCount = 0; protected BaseClass() { Interlocked.Increment(ref _instanceCount); if (_instanceCount > 1) throw new Exception("multiple…
Xaqron
  • 29,931
  • 42
  • 140
  • 205
1
vote
0 answers

Updating list elements is slow

I need to have ten counters that I update in a loop if certain conditions are met. My normal approach would be to create a list of 10 elements and update the elements of this list. Dummy example: my_counters = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for i in…
user2261062
1
vote
1 answer

download counter with symfony

Hi I wish to realize a download counter with symfony 3 in web/.htaccess I have : RewriteRule ^/up/(.*).(jpg|zip|pdf)$ /download/counter/$1/$2 [R,L] in my controller AppBundle/Controller/DefaultController.php I have : /** *…
1
vote
2 answers

How to increment the letter of alphabet by 2 or more instead of 1 each time?

I want to increment a letter by 2 each time, e.g. // increment by 1 $alphabet = "A"; $alphabet++; // 'B' I want something like // increment by 2 $alphabet = "A"; $alphabet+=2; // 'C' How can i do this? I tried the code above but encounter non…
Crazy
  • 847
  • 1
  • 18
  • 41
1
vote
1 answer

VHDL Counter returning 'X', unknown value

I am trying to create a 4 bit counter with instantiated components, shown below. When I simulate, the output toggles between 0 and X(an unknown signal). I'm not sure what is wrong. simulations, circuit diagram and code are shown below. 4 Bit modulo…
Chris
  • 13
  • 5
1
vote
3 answers

Why does my for loop not give intended output in C?

I am trying to add a letter to an array which I've defined in a for loop. For each time the user inputs something, I would like to decrease "counterSoFar" by 1, and display it. However, "counterSoFar" always decreases by 2 and skip an opportunity…
Sarah Collins
  • 225
  • 3
  • 7
  • 18
1
vote
1 answer

limit reward button press to once an hour

I have a reward advert system setup within my app. at the moment every time I press my reward button a reward advert shows. But I want to limit this to one click every hour. this is my button onclick which is situated within my advert loaded method.…
markharrop
  • 866
  • 1
  • 9
  • 30
1
vote
2 answers

Create a new dataframe by aggregating repeated origin and destination values by a separate count column in a pandas dataframe

I am having trouble analysing origin-destination values in a pandas dataframe which contains origin/destination columns and a count column of the frequency of these. I want to transform this into a dataframe with the count of how many are leaving…
Geo_Py
  • 13
  • 2
1
vote
1 answer

How to remove contour's clabel

As we know that we can remove the collections of contour/contourf. But how can I remove the contour's clabel? fig = plt.figure() ax = fig.add_subplots(111) for ivalue in range(10): values = alldata [ivalue,:,:] cs = plt.contour(x,y,vakues) …
Li Ziming
  • 385
  • 2
  • 5
  • 17