-
-/* looks the key up in the cdrs of the alist-keys
- - ignoring the car and ignoring non-pair keys.
- Returns first match found, i.e.
-
- alist = ((1 . 10)
- ((1 . 2) . 11)
- ((2 . 1) . 12)
- ((3 . 0) . 13)
- ((4 . 1) . 14) )
-
- I would like (ly_assoc_cdr 1) to return 12 - because it's the first
- element with the cdr of the key = 1. In other words (alloc_cdr key)
- corresponds to call
-
- (alloc (anything . key))
-*/
-SCM
-ly_assoc_cdr (SCM key, SCM alist)
-{
- if (scm_is_pair (alist))
- {
- SCM trykey = scm_caar (alist);
- if (scm_is_pair (trykey)
- && to_boolean (scm_equal_p (key, scm_cdr (trykey))))
- return scm_car (alist);
- return ly_assoc_cdr (key, scm_cdr (alist));
- }
- return SCM_BOOL_F;
-}
-
-
-bool
-alist_equal_p (SCM a, SCM b)
-{
- for (SCM s = a;
- scm_is_pair (s); s = scm_cdr (s))
- {
- SCM key = scm_caar (s);
- SCM val = scm_cdar (s);
- SCM l = scm_assoc (key, b);
-
- if (l == SCM_BOOL_F
- || !ly_is_equal (scm_cdr (l), val))
-
- return false;
- }
- return true;
-}
-