1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 1998--2011 Jan Nieuwenhuizen <janneke@gnu.org>
4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl>
6 ;;;; LilyPond is free software: you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation, either version 3 of the License, or
9 ;;;; (at your option) any later version.
11 ;;;; LilyPond is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;;; GNU General Public License for more details.
16 ;;;; You should have received a copy of the GNU General Public License
17 ;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
19 ;;; Note: this file can't be used without LilyPond executable
22 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24 (define-public (number-pair? x)
26 (number? (car x)) (number? (cdr x))))
28 (define-public (fraction? x)
30 (integer? (car x)) (integer? (cdr x))
31 (>= (car x) 0) (>= (cdr x) 0)))
33 (define-public (number-or-grob? x)
34 (or (ly:grob? x) (number? x)))
36 (define-public (grob-list? x)
39 (define-public (number-list? x)
40 (and (list? x) (every number? x)))
42 (define-public (moment-pair? x)
44 (ly:moment? (car x)) (ly:moment? (cdr x))))
46 (define-public (boolean-or-symbol? x)
47 (or (boolean? x) (symbol? x)))
49 (define-public (string-or-symbol? x)
50 (or (string? x) (symbol? x)))
52 (define-public (number-or-string? x)
53 (or (number? x) (string? x)))
55 (define-public (string-or-pair? x)
56 (or (string? x) (pair? x)))
58 (define-public (number-or-pair? x)
59 (or (number? x) (pair? x)))
61 (define-public (cheap-list? x)
62 (or (pair? x) (null? x)))
64 (define-public (list-or-symbol? x)
65 (or (cheap-list? x) (symbol? x)))
67 (define-public (scheme? x) #t)
69 (define-public (symbol-or-boolean? x)
70 (or (symbol? x) (boolean? x)))
72 (define-public (void? x)
75 ;; moved list to end of lily.scm: then all type-predicates are
77 (define type-p-name-alist '())
79 (define (match-predicate obj alist)
82 (if (apply (caar alist) obj)
84 (match-predicate obj (cdr alist)))))
86 (define-public (object-type obj)
87 (match-predicate obj type-p-name-alist))
89 (define-public (object-type-name obj)
90 (type-name (match-predicate obj type-p-name-alist)))
92 (define-public (type-name predicate)
93 (let ((entry (assoc predicate type-p-name-alist)))
94 (if (pair? entry) (cdr entry)
96 (symbol->string (procedure-name predicate))