Ejemplo n.º 1
0
def upper_bound(z):
    return max([car(z), cdr(z)])
Ejemplo n.º 2
0
def y_point(point):
    return cdr(point)
Ejemplo n.º 3
0
def lower_bound(z):
    return min([car(z), cdr(z)])
Ejemplo n.º 4
0
def right_bottom(rectangle):
    return cdr(rectangle)
Ejemplo n.º 5
0
def end_segment(segment):
    return cdr(segment)
Ejemplo n.º 6
0
def append(list1, list2):
    if null(list1):
        return list2

    return cons(car(list1), append(cdr(list1), list2))
Ejemplo n.º 7
0
def list_ref(items, n):
    if (n == 0):
        return car(items)

    return list_ref(cdr(items), n - 1)
Ejemplo n.º 8
0
def length(items):
    if (null(items)):
        return 0

    return 1 + length(cdr(items))
Ejemplo n.º 9
0
def denom(x):
    return cdr(x)
Ejemplo n.º 10
0
from util_pair import cons, car, cdr, list, print_list

x = cons(1, cons(2, cons(3, cons(4, None))))
print_list(x)

one_through_four = list([1, 2, 3, 4])
print_list(one_through_four)
print(car(one_through_four))
print_list(cdr(one_through_four))
print(car(cdr(one_through_four)))
print_list(cons(10, one_through_four))
print_list(cons(5, one_through_four))
Ejemplo n.º 11
0
def numer(x):
    g = gcd(car(x), cdr(x))

    return int(car(x) / g)
Ejemplo n.º 12
0
def denom(x):
    g = gcd(car(x), cdr(x))

    return int(cdr(x) / g)