JavaScript Keeping state in curried function

Is there a way to keep some sort of internal state while writing a curried function?

For example, let's say I want to write a curried function that takes into account the number of times the function was called previously.

I.e. addProgressively(3)(4)(5) = 1*3 + 2*4 + 3*5 = 26.

My approach is to add some counter that increments every time a new curried function is returned but I can't find a good way to keep track of that argument within the addProgressively function.

Answer:1

I am figuring out of i can make something like Google analytics script. They work with javascript to capture data and send it to an given URL. But i want it to do without ajax or REST API. What i ...

I am figuring out of i can make something like Google analytics script. They work with javascript to capture data and send it to an given URL. But i want it to do without ajax or REST API. What i ...

I am using this code to let user draw circles or images drawingManager = new google.maps.drawing.DrawingManager({ drawingMode: null, drawingControlOptions: { ...

I am using this code to let user draw circles or images drawingManager = new google.maps.drawing.DrawingManager({ drawingMode: null, drawingControlOptions: { ...

  1. wpf custom drawing control
  2. custom drawing treeview control
  3. custom control not drawing

Why is the result of the following code 1 and not 10? Why doesn't the function bar() change the value, even though there is a return statement. var foo = 1; function bar() { foo = 10; return; ...

Why is the result of the following code 1 and not 10? Why doesn't the function bar() change the value, even though there is a return statement. var foo = 1; function bar() { foo = 10; return; ...

  1. what function creates the frame that holds the drawing
  2. what function creates a circle
  3. what function creates a parabola
  4. what creates a function
  5. what statement creates a function in python
  6. what statement creates a function

I wonder how to display the scale map in leafleat.js. That is: I want this instead of this (taken to leaflet tutorial). See the left corner of the picture.

I wonder how to display the scale map in leafleat.js. That is: I want this instead of this (taken to leaflet tutorial). See the left corner of the picture.

  1. leaflet display scale