示例#1
0
def expand_clauses(clauses):
    if clauses is EmptyList:
        return Boolean(False)

    first = car(clauses)
    rest = cdr(clauses)

    if is_cond_else_clause(first):
        if rest is EmptyList:
            return sequence_expr(cond_actions(first))
        else:
            raise ValueError('ELSE caluse isn\'t last: %s' % clauses)
    else:
        return make_if(cond_predicate(first), 
                sequence_expr(cond_actions(first)), expand_clauses(rest))
示例#2
0
def rest_operands(ops):
    return cdr(ops)
示例#3
0
def operands(expr):
    return cdr(expr)
示例#4
0
def rest_exprs(seq):
    return cdr(seq)
示例#5
0
def is_last_expr(seq):
    return cdr(seq) is EmptyList
示例#6
0
def begin_actions(expr):
    return cdr(expr)
示例#7
0
 def inner(arg, count):
     if arg is EmptyList:
         return count
     return inner(cdr(arg), count + 1)
示例#8
0
def cond_clauses(expr):
    return cdr(expr)
示例#9
0
def cond_actions(clause):
    return cdr(clause)
示例#10
0
 def inner(expr):
     if expr is EmptyList:
         return EmptyList
     return cons(cadar(expr), inner(cdr(expr)))
示例#11
0
文件: builtin.py 项目: tsingcoo/study
 def inner(arg, count):
     if arg is EmptyList:
         return count
     return inner(cdr(arg), count + 1)
示例#12
0
def rest_exprs(seq):
    return cdr(seq)
示例#13
0
def is_last_expr(seq):
    return cdr(seq) is EmptyList
示例#14
0
def begin_actions(expr):
    return cdr(expr)