picrin/include/picrin/pair.h

69 lines
2.4 KiB
C
Raw Normal View History

2014-01-17 06:58:31 -05:00
/**
* See Copyright Notice in picrin.h
*/
2014-01-23 02:47:13 -05:00
#ifndef PICRIN_PAIR_H__
#define PICRIN_PAIR_H__
2013-10-19 23:34:57 -04:00
2014-01-17 22:41:39 -05:00
#if defined(__cplusplus)
extern "C" {
#endif
struct pic_pair {
PIC_OBJECT_HEADER
pic_value car;
pic_value cdr;
};
#define pic_pair_p(v) (pic_type(v) == PIC_TT_PAIR)
#define pic_pair_ptr(o) ((struct pic_pair *)pic_ptr(o))
2013-10-19 23:34:57 -04:00
pic_value pic_cons(pic_state *, pic_value, pic_value);
pic_value pic_car(pic_state *, pic_value);
pic_value pic_cdr(pic_state *, pic_value);
bool pic_list_p(pic_value);
2014-03-01 06:46:08 -05:00
pic_value pic_list1(pic_state *, pic_value);
pic_value pic_list2(pic_state *, pic_value, pic_value);
pic_value pic_list3(pic_state *, pic_value, pic_value, pic_value);
pic_value pic_list4(pic_state *, pic_value, pic_value, pic_value, pic_value);
pic_value pic_list5(pic_state *, pic_value, pic_value, pic_value, pic_value, pic_value);
pic_value pic_list6(pic_state *, pic_value, pic_value, pic_value, pic_value, pic_value, pic_value);
2014-03-27 04:00:36 -04:00
pic_value pic_list7(pic_state *, pic_value, pic_value, pic_value, pic_value, pic_value, pic_value, pic_value);
2014-02-01 22:25:34 -05:00
pic_value pic_list_by_array(pic_state *, size_t, pic_value *);
pic_value pic_make_list(pic_state *, int, pic_value);
2013-10-19 23:34:57 -04:00
2014-03-03 08:21:34 -05:00
#define pic_for_each(var, list) \
2014-03-19 04:55:52 -04:00
pic_for_each_helper__(var, GENSYM(tmp), list)
2014-03-03 08:21:34 -05:00
#define pic_for_each_helper__(var, tmp, list) \
2014-02-01 02:04:57 -05:00
for (pic_value tmp = (list); \
pic_nil_p(tmp) ? false : ((var = pic_car(pic, tmp)), true); \
tmp = pic_cdr(pic, tmp))
#define pic_push(pic, item, place) (place = pic_cons(pic, item, place))
#define pic_pop(pic, place) (place = pic_cdr(pic, place))
int pic_length(pic_state *, pic_value);
2013-10-21 11:19:43 -04:00
pic_value pic_reverse(pic_state *, pic_value);
2014-01-22 06:57:14 -05:00
pic_value pic_append(pic_state *, pic_value, pic_value);
2013-10-21 11:19:43 -04:00
2013-10-19 23:34:57 -04:00
pic_value pic_assq(pic_state *, pic_value key, pic_value assoc);
2013-12-07 09:30:21 -05:00
pic_value pic_assoc(pic_state *, pic_value key, pic_value assoc);
2013-10-20 01:04:39 -04:00
pic_value pic_acons(pic_state *, pic_value key, pic_value val, pic_value assoc);
2013-10-19 23:34:57 -04:00
2013-11-26 05:42:13 -05:00
pic_value pic_caar(pic_state *, pic_value);
pic_value pic_cadr(pic_state *, pic_value);
pic_value pic_cdar(pic_state *, pic_value);
pic_value pic_cddr(pic_state *, pic_value);
2014-02-22 20:51:21 -05:00
pic_value pic_list_tail(pic_state *, pic_value, int);
2014-01-22 06:57:05 -05:00
pic_value pic_list_ref(pic_state *, pic_value, int);
2014-01-22 07:35:13 -05:00
void pic_list_set(pic_state *, pic_value, int, pic_value);
pic_value pic_list_copy(pic_state *, pic_value);
2014-01-22 06:57:05 -05:00
2014-01-17 22:41:39 -05:00
#if defined(__cplusplus)
}
#endif
2013-10-19 23:34:57 -04:00
#endif