static int exec_neq(node_ctx* ctx, int argc, strm_value* args, strm_value* ret) { assert(argc == 2); *ret = strm_bool_value(!strm_value_eq(args[0], args[1])); return 0; }
static int exec_neq(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { assert(argc == 2); *ret = strm_bool_value(!strm_value_eq(args[0], args[1])); return STRM_OK; }
static int list_ary_eq(strm_list* a, strm_array* b) { size_t i, j, len; for (i=0, len=b->len; a && i<len; i++) { if (!strm_value_eq(a->car, b->ptr[i])) return FALSE; a = a->cdr; if (a && a->type == STRM_OBJ_ARRAY) { for (j=0; i<len; i++, j++) { strm_array *a2 = (strm_array*)a; if (!strm_value_eq(a2->ptr[j], b->ptr[i])) return FALSE; } return TRUE; } } return i==len; }
int strm_ary_eq(strm_array a, strm_array b) { strm_int i, len; if (a == b) return TRUE; if (strm_ary_len(a) != strm_ary_len(b)) return FALSE; for (i=0, len=strm_ary_len(a); i<len; i++) { if (!strm_value_eq(strm_ary_ptr(a)[i], strm_ary_ptr(b)[i])) { return FALSE; } } return TRUE; }
static int iter_uniq(strm_stream* strm, strm_value data) { struct uniq_data* d = strm->data; if (!d->init) { d->init = TRUE; d->last = data; strm_emit(strm, data, NULL); return STRM_OK; } if (!strm_value_eq(data, d->last)) { d->last = data; strm_emit(strm, data, NULL); } return STRM_OK; }
int strm_list_eq(strm_list* a, strm_list* b) { if (a == b) return TRUE; if (a->len != b->len) return FALSE; for (;;) { if (a->type == STRM_OBJ_ARRAY) { if (b->type == STRM_OBJ_ARRAY) { return strm_ary_eq((strm_array*)a, (strm_array*)b); } return list_ary_eq(b, (strm_array*)a); } if (b->type == STRM_OBJ_ARRAY) { return list_ary_eq(a, (strm_array*)b); } if (!strm_value_eq(a->car, b->car)) return FALSE; a = a->cdr; if (!a) return FALSE; b = b->cdr; if (!b) return FALSE; } return TRUE; }
static int iter_uniqf(strm_stream* strm, strm_value data) { struct uniq_data* d = strm->data; strm_value val; if (strm_funcall(strm, d->func, 1, &data, &val) == STRM_NG) { return STRM_NG; } if (!d->init) { d->init = TRUE; d->last = data; d->v = val; strm_emit(strm, data, NULL); return STRM_OK; } if (!strm_value_eq(val, d->v)) { d->last = data; d->v = val; strm_emit(strm, data, NULL); } return STRM_OK; }