Skip to content

Latest commit

 

History

History
46 lines (22 loc) · 1.01 KB

primitives.rst

File metadata and controls

46 lines (22 loc) · 1.01 KB

Primitives

isnone(x)

Checks if x is None. Handy with filtering functions:

_, data = lsplit_by(isnone, dirty_data) # Skip leading nones

Plays nice with silent, which returns None on fail:

remove(isnone, map(silent(int), strings_with_numbers))

Note that it's usually simpler to use keep or compact if you don't need to distinguish between None and other falsy values.

notnone(x)

Checks if x is not None. A shortcut for complement(isnone) meant to be used when bool is not specific enough. Compare:

select_values(notnone, data_dict) # removes None values
compact(data_dict)                # removes all falsy values

inc(x)

Increments its argument by 1.

dec(x)

Decrements its argument by 1.

even(x)

Checks if x is even.

odd(x)

Checks if x is odd.