/_false? { false eq } def
/_string? {
dup type /stringtype eq {
- dup length 0 eq { % length > 0
+ dup length 0 eq { % if length == 0
pop true
}{
0 get 127 eq not
/_keyword? {
dup type /stringtype eq {
- 0 get 127 eq
+ dup length 0 eq { % if length == 0
+ pop false
+ }{
+ 0 get 127 eq
+ } ifelse
}{
pop false
} ifelse
def _nil_Q(exp): return exp is None
def _true_Q(exp): return exp is True
def _false_Q(exp): return exp is False
-def _string_Q(exp): return type(exp) in str_types
+def _string_Q(exp):
+ if type(exp) in str_types:
+ return len(exp) == 0 or exp[0] != _u("\u029e")
+ else:
+ return False
# Symbols
class Symbol(str): pass
# A specially prefixed string
def _keyword(str):
if str[0] == _u("\u029e"): return str
- else: return _u("\u029e") + str
+ else: return _u("\u029e") + str
def _keyword_Q(exp):
- return _string_Q(exp) and exp[0] == _u("\u029e")
+ if type(exp) in str_types:
+ return len(exp) != 0 and exp[0] == _u("\u029e")
+ else:
+ return False
# Functions
def _function(Eval, Env, ast, env, params):
for k in obj.keys():
ret.extend((_pr_str(k), _pr_str(obj[k],_r)))
return "{" + " ".join(ret) + "}"
- elif types._string_Q(obj):
+ elif type(obj) in types.str_types:
if len(obj) > 0 and obj[0] == types._u('\u029e'):
return ':' + obj[1:]
elif print_readably: