add pic_assoc
This commit is contained in:
parent
28da6d71ba
commit
24a41d8e27
|
@ -13,6 +13,7 @@ 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_assq(pic_state *, pic_value key, pic_value assoc);
|
pic_value pic_assq(pic_state *, pic_value key, pic_value assoc);
|
||||||
|
pic_value pic_assoc(pic_state *, pic_value key, pic_value assoc);
|
||||||
pic_value pic_acons(pic_state *, pic_value key, pic_value val, pic_value assoc);
|
pic_value pic_acons(pic_state *, pic_value key, pic_value val, pic_value assoc);
|
||||||
|
|
||||||
pic_value pic_caar(pic_state *, pic_value);
|
pic_value pic_caar(pic_state *, pic_value);
|
||||||
|
|
18
src/pair.c
18
src/pair.c
|
@ -128,6 +128,24 @@ pic_assq(pic_state *pic, pic_value key, pic_value assoc)
|
||||||
goto enter;
|
goto enter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pic_value
|
||||||
|
pic_assoc(pic_state *pic, pic_value key, pic_value assoc)
|
||||||
|
{
|
||||||
|
pic_value cell;
|
||||||
|
|
||||||
|
enter:
|
||||||
|
|
||||||
|
if (pic_nil_p(assoc))
|
||||||
|
return assoc;
|
||||||
|
|
||||||
|
cell = pic_car(pic, assoc);
|
||||||
|
if (pic_equal_p(pic, key, pic_car(pic, cell)))
|
||||||
|
return cell;
|
||||||
|
|
||||||
|
assoc = pic_cdr(pic, assoc);
|
||||||
|
goto enter;
|
||||||
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
pic_acons(pic_state *pic, pic_value key, pic_value val, pic_value assoc)
|
pic_acons(pic_state *pic, pic_value key, pic_value val, pic_value assoc)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue