示例#1
0
文件: numbers.py 项目: foodhype/pixie
def _sub(a, b):
    assert isinstance(a, Ratio) and isinstance(b, Ratio)
    return rt._div(rt._add(rt.wrap(-1 * b.numerator() * a.denominator()),
                           rt.wrap(a.numerator() * b.denominator())),
                   rt.wrap(a.denominator() * b.denominator()))
示例#2
0
def gensym2(prefix):
    rt.reset_BANG_(gensym_id, rt._add(rt.deref(gensym_id), rt.wrap(1)))
    i = rt.deref(gensym_id)

    return rt.symbol(rt.str(prefix, i))
示例#3
0
def gensym2(prefix):
    rt.reset_BANG_(gensym_id, rt._add(rt.deref(gensym_id), rt.wrap(1)))
    i = rt.deref(gensym_id)

    return rt.symbol(rt.str(prefix, i))
示例#4
0
def gensym():
    rt.reset_BANG_(gensym_id, rt._add(rt.deref(gensym_id), rt.wrap(1)))
    i = rt.deref(gensym_id)

    return rt.symbol(rt.str(rt.wrap(u"gensym_"), i))
示例#5
0
def _add(a, b):
    assert isinstance(a, Character) and isinstance(b, Integer)
    return rt._add(rt.wrap(a.char_val()), b)
示例#6
0
def _add(a, b):
    assert isinstance(a, Character) and isinstance(b, Integer)
    return rt._add(rt.wrap(a.char_val()), b)
示例#7
0
def _sub(a, b):
    assert isinstance(a, Ratio) and isinstance(b, Ratio)
    return rt._div(
        rt._add(rt.wrap(-1 * b.numerator() * a.denominator()),
                rt.wrap(a.numerator() * b.denominator())),
        rt.wrap(a.denominator() * b.denominator()))