I would use s7_iterate which underlies map and for-each:

    s7_pointer iter, hash, x;
    s7_int gc1, gc2;

    hash = s7_make_hash_table(sc, 8);
    gc1 = s7_gc_protect(sc, hash);
s7_hash_table_set(sc, hash, s7_make_symbol(sc, "a"), s7_make_integer(sc, 1)); s7_hash_table_set(sc, hash, s7_make_symbol(sc, "b"), s7_make_integer(sc, 2));

    iter = s7_make_iterator(sc, hash);
    gc2 = s7_gc_protect(sc, iter);

    x = s7_iterate(sc, iter);  /* (a . 1) */
    fprintf(stderr, "x: %s\n", s7_object_to_c_string(sc, x));
    x = s7_iterate(sc, iter);  /* (b . 2) */
    fprintf(stderr, "x: %s\n", s7_object_to_c_string(sc, x));
    x = s7_iterate(sc, iter);  /* #<eof> == end */
    fprintf(stderr, "x: %s\n", s7_object_to_c_string(sc, x));

    s7_gc_unprotect_at(sc, gc1);
    s7_gc_unprotect_at(sc, gc2);

_______________________________________________
Cmdist mailing list
[email protected]
https://cm-mail.stanford.edu/mailman/listinfo/cmdist

Reply via email to