Count: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m } => )
imported>Bale
mNo edit summary
Line 5: Line 5:
FunctionPage|
FunctionPage|
name={{#var:name}}|
name={{#var:name}}|
function_category=Miscellaneous|


function1={{Function|
function1={{Function|
Line 32: Line 31:
special=This function returns 0 for an empty map (i.e. with 0 keys).
special=This function returns 0 for an empty map (i.e. with 0 keys).
}}
}}
[[Category:Miscellaneous Functions]]

Revision as of 05:31, 22 May 2010

Function Syntax

int count(aggregate map )

Returns the number of keys in the specified aggregate.

Code Samples

This example function uses count to create a new key in a map (defined outside the function to hopefully eliminate some confusion).

item [int] my_map;
boolean newkey(item i) {
   map[count(map)] = i;
}

See Also

clear() | file_to_map() | map_to_file()

Special

This function returns 0 for an empty map (i.e. with 0 keys).