Exemple #1
0
def lower_bound(z):
    return min([car(z), cdr(z)])
Exemple #2
0
def upper_bound(z):
    return max([car(z), cdr(z)])
Exemple #3
0
def x_point(point):
    return car(point)
Exemple #4
0
def start_segment(segment):
    return car(segment)
Exemple #5
0
def list_ref(items, n):
    if (n == 0):
        return car(items)

    return list_ref(cdr(items), n - 1)
Exemple #6
0
def left_top(rectangle):
    return car(rectangle)
Exemple #7
0
def append(list1, list2):
    if null(list1):
        return list2

    return cons(car(list1), append(cdr(list1), list2))
Exemple #8
0
def numer(x):
    return car(x)
Exemple #9
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))
Exemple #10
0
def numer(x):
    g = gcd(car(x), cdr(x))

    return int(car(x) / g)
Exemple #11
0
def denom(x):
    g = gcd(car(x), cdr(x))

    return int(cdr(x) / g)