How many? is a typical question that comes up when programming. I use a variety of software for projects and there are subtly different ways to answer that question depending on the context.
Here is an alphabetical list of ways I’ve recently answered that question. A more detailed comparison of programming languages can be found on Wikipedia.
# How many rows are in this file?
wc -l < file
// How many elements are in this array?
len(array)
// How many elements are in this array?
array.length
// How many elements in this array are greater than 5?
d3.count(array, (d) => d > 5)
// How many rows are in this Apache Arrow table?
table.numRows
<!-- How many elements are in this array? -->
array | size
# How many elements are in this list?
len(list)
# How many elements are in this pandas dataframe?
df.size # including missing values
df.count() # excluding missing values
# How many elements are in this numpy array?
ndarray.size
# How many elements are in this array?
array.length
array.count
array.size
# How many rows are in this Active Record table?
table.count
-- How many elements are in this PostgreSQL array?
array_length(array, 1)
-- How many elements are in this DuckDB list?
len(list)
-- How many rows are in this table?
select count(*) from table
# How many elements are in this list?
length(list)
Update: Flickr has released version 2.0.1 so this is no longer necessary. Thanks Flickr :D
read more »There is an undocumented case where the output of an internal function is different in PHP 5.2 vs PHP 5.3 when you pass it an invalid argument.
read more »The term 'load-bearing code' can be used to refer to software that exhibits the following attributes.
Jerry, these are load-bearing walls, they're not gonna come down!
Cosmo Kramer in the Seinfeld episode "The Chicken Roaster"
I have encountered load-bearing code in legacy open source applications, inherited projects, or debugging production software.
How many different Mii designs are possible? I started counting the options, did the math, and here are the results.
Attribute | Options | |
---|---|---|
1 | Genders | 2 |
2 | Clothing Colors | 12 |
3 | Heights | 10 |
4 | Weights | 10 |
5 | Face Shapes | 8 |
6 | Makeup Types | 12 |
7 | Skin Colors | 6 |
8 | Hair Styles | 72 |
9 | Hair Parts | 2 |
10 | Hair Colors | 8 |
11 | Eyebrows | 24 |
12 | Eyebrow Colors | 8 |
13 | Eyebrow Vertical Steps | 16 |
14 | Eyebrow Size Steps | 9 |
15 | Eyebrow Rotation Steps | 12 |
16 | Eyebrow Horizontal Steps | 13 |
17 | Eye Types | 42 |
18 | Eye Colors | 6 |
19 | Eye Vertical Steps | 19 |
20 | Eye Size Steps | 8 |
21 | Eye Rotation Steps | 8 |
22 | Eye Horizontal Steps | 13 |
23 | Noses | 12 |
24 | Nose Vertical Steps | 19 |
25 | Nose Sizes | 9 |
26 | Lips | 24 |
27 | Lips Colors | 3 |
28 | Lips Vertical Steps | 19 |
29 | Lips Sizes | 9 |
30 | Glasses | 9 |
31 | Glasses Colors | 6 |
32 | Glasses Vertical Steps | 21 |
33 | Glasses Sizes | 8 |
34 | Mustaches | 4 |
35 | Mustache Colors | 8 |
36 | Mustache Vertical Steps | 17 |
37 | Mustache Sizes | 9 |
38 | Moles | 2 |
39 | Mole Vertical Steps | 31 |
40 | Mole Sizes | 9 |
41 | Mole Horizontal Steps | 17 |
42 | Goatee Types | 4 |
43 | Goatee Colors | 8 |
Total | 568 |