refactor pic_for_each
This commit is contained in:
parent
34bcabf5bc
commit
464925d220
|
@ -32,14 +32,13 @@ pic_value pic_list6(pic_state *, pic_value, pic_value, pic_value, pic_value, pic
|
||||||
pic_value pic_list_by_array(pic_state *, size_t, pic_value *);
|
pic_value pic_list_by_array(pic_state *, size_t, pic_value *);
|
||||||
pic_value pic_make_list(pic_state *, int, pic_value);
|
pic_value pic_make_list(pic_state *, int, pic_value);
|
||||||
|
|
||||||
#define PIC_FOR_EACH_HELPER(var, tmp, list) \
|
#define pic_for_each(var, list) \
|
||||||
|
pic_for_each_helper__(var, GENSYM(pic_for_each_tmp__), list)
|
||||||
|
#define pic_for_each_helper__(var, tmp, list) \
|
||||||
for (pic_value tmp = (list); \
|
for (pic_value tmp = (list); \
|
||||||
pic_nil_p(tmp) ? false : ((var = pic_car(pic, tmp)), true); \
|
pic_nil_p(tmp) ? false : ((var = pic_car(pic, tmp)), true); \
|
||||||
tmp = pic_cdr(pic, tmp))
|
tmp = pic_cdr(pic, tmp))
|
||||||
|
|
||||||
#define pic_for_each(var, list) \
|
|
||||||
PIC_FOR_EACH_HELPER(var, GENSYM(pic_for_each_tmp__), list) \
|
|
||||||
|
|
||||||
int pic_length(pic_state *, pic_value);
|
int pic_length(pic_state *, pic_value);
|
||||||
pic_value pic_reverse(pic_state *, pic_value);
|
pic_value pic_reverse(pic_state *, pic_value);
|
||||||
pic_value pic_append(pic_state *, pic_value, pic_value);
|
pic_value pic_append(pic_state *, pic_value, pic_value);
|
||||||
|
|
Loading…
Reference in New Issue