Question

The crossfilter group.reduce add and remove functions take parameters p and v. What are p and v short for in this context?

In numerous crossfilter examples, crossfilter is stored in a variable called ndx. What is ndx short for?

Thanks,

Nathan

Was it helpful?

Solution

group.reduce follows a similar pattern to the JS built-in Array.reduce with the first argument of the callback being the previous value and the second argument being the current value.

So, p is the value returned by the previous invocation (or the value returned from init in first iteration) and c is the current value for the row being operated on.

OTHER TIPS

The common use of ndx for the crossfilter variable name has been bugging me as well, so I've been looking into it.

The only clear connection I can find is that a quick google of "ndx" returns a lot to do with the NASDAQ 100 Index. Given that an accessible example of crossfilter in action comes from an example of dc.js used to chart data from this very index (see dc-js.github.io/dc.js/), it seems that many people have picked it up from there and just run with it.

The official crossfilter example certainly doesn't use ndx.

I know this is an old question, but I just came across this abbreviation in some legacy code at my company and wanted to share my insight for the next person who googles "ndx". In my case at least, it literally was just short for "Index". Get, it? "N-dx", sound it out.

I spent days reading it as N.D.X and trying to figure out if it was some sort of high level statistics thing that I didn't understand. Nope, just a for-loop index.

People need to realize how important good variable naming is to readability. Those 2 omitted characters caused me indescribable heartache.

I also found "ndx" referenced in this Hungarian notation wiki as "of or pertaining to an Index ( or Mdx )".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top