Esempio n. 1
0
tp_obj tp_range(TP) {
    int a = TP_NUM();
    int b = TP_NUM();
    int c = TP_DEFAULT(tp_number(1)).number.val;
    tp_obj r = tp_list(tp);
    int i;
    for (i=a; i!=b; i+=c) { _tp_list_append(tp,r.list.val,tp_number(i)); }
    return r;
}
Esempio n. 2
0
tp_obj tp_range(TP) {
    int a,b,c,i;
    tp_obj r = tp_list(tp);
    switch (tp->params.list.val->len) {
        case 1: a = 0; b = TP_NUM(); c = 1; break;
        case 2:
        case 3: a = TP_NUM(); b = TP_NUM(); c = TP_DEFAULT(tp_number(1)).number.val; break;
        default: return r;
    }
    if (c != 0) {
        for (i=a; (c>0) ? i<b : i>b; i+=c) {
            _tp_list_append(tp,r.list.val,tp_number(i));
        }
    }
    return r;
}
Esempio n. 3
0
File: math.c Progetto: Saruta/pyr0
tp_obj math_sqrt(TP)
{
	double x = TP_NUM();
	double r = 0.0;
	r = sqrt(x);
	return (tp_number(r));
}
Esempio n. 4
0
File: math.c Progetto: Saruta/pyr0
tp_obj math_acos(TP)
{
	double x = TP_NUM();
	double r = 0.0;
	r = acos(x);
	return (tp_number(r));
}
Esempio n. 5
0
File: math.c Progetto: Saruta/pyr0
tp_obj math_ceil(TP)
{
	double x = TP_NUM();
	double r = 0.0;
	r = ceil(x);
	return (tp_number(r));
}
Esempio n. 6
0
File: math.c Progetto: Saruta/pyr0
tp_obj math_exp(TP)
{
	double x = TP_NUM();
	double r = 0.0;
	r = exp(x);
	return (tp_number(r));
}
Esempio n. 7
0
File: math.c Progetto: Saruta/pyr0
tp_obj math_tan(TP)
{
	double x = TP_NUM();
	double r = 0.0;
	r = tan(x);
	return (tp_number(r));
}
Esempio n. 8
0
tp_obj tp_assert(TP) {
    int a = TP_NUM();
    if (a) { return None; }
    tp_raise(None,"%s","assert failed");
}
Esempio n. 9
0
tp_obj tp_fpack(TP) {
    tp_num v = TP_NUM();
    tp_obj r = tp_string_t(tp,sizeof(tp_num));
    *(tp_num*)r.string.val = v; 
    return tp_track(tp,r);
}
Esempio n. 10
0
tp_obj tp_chr(TP) {
    int v = TP_NUM();
    return tp_string_n(tp->chars[(unsigned char)v],1);
}
Esempio n. 11
0
tp_obj tp_assert(TP) {
    int a = TP_NUM();
    if (a) { return tp_None; }
    tp_raise(tp_None,tp_string("(tp_assert) AssertionError"));
}