Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1998--2011 Jan Nieuwenhuizen <janneke@gnu.org> | 4 Copyright (C) 1998--2011 Jan Nieuwenhuizen <janneke@gnu.org> |
5 Han-Wen Nienhuys <hanwen@xs4all.nl> | 5 Han-Wen Nienhuys <hanwen@xs4all.nl> |
6 | 6 |
7 LilyPond is free software: you can redistribute it and/or modify | 7 LilyPond is free software: you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation, either version 3 of the License, or | 9 the Free Software Foundation, either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 | 171 |
172 unsigned int | 172 unsigned int |
173 ly_scm_hash (SCM s) | 173 ly_scm_hash (SCM s) |
174 { | 174 { |
175 return scm_ihashv (s, ~1u); | 175 return scm_ihashv (s, ~1u); |
176 } | 176 } |
177 | 177 |
178 bool | 178 bool |
179 is_axis (SCM s) | 179 is_axis (SCM s) |
180 { | 180 { |
181 if (scm_is_number (s)) | 181 if (scm_is_integer (s)) |
182 { | 182 { |
183 int i = scm_to_int (s); | 183 int i = scm_to_int (s); |
184 return i == 0 || i == 1; | 184 return i == 0 || i == 1; |
185 } | 185 } |
186 return false; | 186 return false; |
187 } | 187 } |
188 | 188 |
189 bool | 189 bool |
190 to_boolean (SCM s) | 190 to_boolean (SCM s) |
191 { | 191 { |
(...skipping 27 matching lines...) Expand all Loading... | |
219 } | 219 } |
220 return false; | 220 return false; |
221 } | 221 } |
222 | 222 |
223 /* | 223 /* |
224 INTERVALS | 224 INTERVALS |
225 */ | 225 */ |
226 Interval | 226 Interval |
227 ly_scm2interval (SCM p) | 227 ly_scm2interval (SCM p) |
228 { | 228 { |
229 return Interval (scm_to_double (scm_car (p)), scm_to_double (scm_cdr (p))); | 229 return Interval (scm_to_double (scm_car (p)), |
230 scm_to_double (scm_cdr (p))); | |
230 } | 231 } |
231 | 232 |
232 Drul_array<Real> | 233 Drul_array<Real> |
233 ly_scm2realdrul (SCM p) | 234 ly_scm2realdrul (SCM p) |
234 { | 235 { |
235 return Drul_array<Real> (scm_to_double (scm_car (p)), | 236 return Drul_array<Real> (scm_to_double (scm_car (p)), |
236 scm_to_double (scm_cdr (p))); | 237 scm_to_double (scm_cdr (p))); |
237 } | 238 } |
238 | 239 |
239 SCM | 240 SCM |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 vector<Offset> os; | 315 vector<Offset> os; |
315 for (; scm_is_pair (s); s = scm_cdr (s)) | 316 for (; scm_is_pair (s); s = scm_cdr (s)) |
316 os.push_back (ly_scm2offset (scm_car (s))); | 317 os.push_back (ly_scm2offset (scm_car (s))); |
317 return os; | 318 return os; |
318 } | 319 } |
319 | 320 |
320 /* | 321 /* |
321 ALIST | 322 ALIST |
322 */ | 323 */ |
323 | 324 |
325 // This one is used nowhere. | |
dak
2011/10/23 21:23:11
If it is used nowhere, it should be removed. It i
| |
324 bool | 326 bool |
325 alist_equal_p (SCM a, SCM b) | 327 ly_is_alist_equal (SCM a, SCM b) |
326 { | 328 { |
327 for (SCM s = a; | 329 if (!scm_is_pair (a) || !scm_is_pair (b)) |
dak
2011/10/23 21:23:11
This returns false even if both alists are empty.
| |
328 scm_is_pair (s); s = scm_cdr (s)) | 330 return false; |
331 for (SCM s = a; scm_is_pair (s); s = scm_cdr (s)) | |
329 { | 332 { |
330 SCM key = scm_caar (s); | 333 SCM key = scm_caar (s); |
331 SCM val = scm_cdar (s); | 334 SCM val = scm_cdar (s); |
332 SCM l = scm_assoc (key, b); | 335 SCM l = scm_assoc (key, b); |
333 | 336 |
334 if (l == SCM_BOOL_F | 337 if (scm_is_false (l) || !ly_is_equal (scm_cdr (l), val)) |
335 || !ly_is_equal (scm_cdr (l), val)) | |
336 | |
337 return false; | 338 return false; |
338 } | 339 } |
339 return true; | 340 return true; |
dak
2011/10/23 21:23:11
This returns true if every pair in list a is also
| |
340 } | 341 } |
341 | 342 |
342 SCM | 343 SCM |
343 ly_alist_vals (SCM alist) | 344 ly_alist_vals (SCM alist) |
344 { | 345 { |
345 SCM x = SCM_EOL; | 346 SCM x = SCM_EOL; |
346 for (SCM p = alist; scm_is_pair (p); p = scm_cdr (p)) | 347 for (SCM p = alist; scm_is_pair (p); p = scm_cdr (p)) |
347 x = scm_cons (scm_cdar (p), x); | 348 x = scm_cons (scm_cdar (p), x); |
348 return x; | 349 return x; |
349 } | 350 } |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 SCM c; | 660 SCM c; |
660 SCM d; | 661 SCM d; |
661 }; | 662 }; |
662 | 663 |
663 /* inserts at front, removing duplicates */ | 664 /* inserts at front, removing duplicates */ |
664 SCM ly_assoc_prepend_x (SCM alist, SCM key, SCM val) | 665 SCM ly_assoc_prepend_x (SCM alist, SCM key, SCM val) |
665 { | 666 { |
666 return scm_acons (key, val, scm_assoc_remove_x (alist, key)); | 667 return scm_acons (key, val, scm_assoc_remove_x (alist, key)); |
667 } | 668 } |
668 | 669 |
OLD | NEW |