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

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

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

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

    return int(cdr(x) / g)