*** TeXmacs-1.0.0.18-src/TeXmacs-1.0.0.18/progs/boot/base.scm --- TeXmacs-1.0.0.18-src/TeXmacs-1.0.0.18/progs/boot/base.scm *************** (define (force-string s) *** 192,216 **** "Return s or \"\" if s in not a string." (if (string? s) s "")) ! (define (func? . l) "(func? x f [n]) -> boolean. Test car, and optionally length, of list x. Is x a list [of n elements] whose first element 'equal?' f?" ! (let ((n (length l))) ! (cond ((= n 2) ! (let ((x (car l)) (f (cadr l))) ! (and (list? x) (not (null? x)) (equal? (car x) f)))) ! ((= n 3) ! (let ((x (car l)) (f (cadr l)) (nn (caddr l))) (and (list? x) (not (null? x)) (equal? (car x) f) (= (length x) (+ nn 1))))) ! (else #f)))) ! (define (tuple? . args) "(tuple? x [f [n]]) -> boolean. Applies 'list?' or 'func?'. Equivalent to 'list?' if f and n are ommited, or equivalent to 'func?'." ! (if (null? (cdr args)) (list? (car args)) (apply func? args))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Patterns --- 192,215 ---- "Return s or \"\" if s in not a string." (if (string? s) s "")) ! (define (func? x f . opts) "(func? x f [n]) -> boolean. Test car, and optionally length, of list x. Is x a list [of n elements] whose first element 'equal?' f?" ! (let ((n (length opts))) ! (cond ((= n 0) ! (and (list? x) (not (null? x)) (equal? (car x) f))) ! ((= n 1) ! (let ((nn (car opts))) (and (list? x) (not (null? x)) (equal? (car x) f) (= (length x) (+ nn 1))))) ! (else (error "Too many arguments."))))) ! (define (tuple? x . opts) "(tuple? x [f [n]]) -> boolean. Applies 'list?' or 'func?'. Equivalent to 'list?' if f and n are ommited, or equivalent to 'func?'." ! (if (null? opts) (list? x) (apply func? (cons x opts)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Patterns