2018-04-01 18:24:09 +00:00
|
|
|
'''
|
|
|
|
Analogous to erlang ones.
|
|
|
|
|
|
|
|
"An atom is a literal, a constant with name."
|
|
|
|
'''
|
|
|
|
|
|
|
|
from collections import namedtuple
|
|
|
|
|
|
|
|
Atom = namedtuple('Atom', field_names='name')
|
|
|
|
|
2018-04-15 18:06:21 +00:00
|
|
|
def is_atom(element, name=None):
|
|
|
|
'''Check if an element is an atom with a specific name.'''
|
|
|
|
if not isinstance(element, Atom):
|
|
|
|
return False
|
|
|
|
|
|
|
|
if name is None:
|
|
|
|
return True
|
|
|
|
|
|
|
|
return element.name == name
|
2018-04-01 18:24:09 +00:00
|
|
|
|
|
|
|
def a(name):
|
|
|
|
'''Build an atom with a given name.'''
|
|
|
|
return Atom(name)
|