/usr/share/scheme48-1.9/big/big-util.scm is in scheme48 1.9-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | ; Part of Scheme 48 1.9. See file COPYING for notices and license.
; Authors: Richard Kelsey, Jonathan Rees, Mike Sperber, Robert Ransom
(define (concatenate-symbol . stuff)
(string->symbol
(apply string-append
(map (lambda (x)
(cond ((string? x) x)
((symbol? x) (symbol->string x))
((number? x) (number->string x))
(else
(assertion-violation 'concatenate-symbol "cannot coerce to a string"
x))))
stuff))))
(define (error format-string . args)
(if #t ; work around a bug in the type system
(rts-error 'error (apply format (cons #f (cons format-string args))))))
(define (breakpoint format-string . args)
(rts-breakpoint (apply format (cons #f (cons format-string args)))))
(define (atom? x)
(not (pair? x)))
(define (neq? x y)
(not (eq? x y)))
(define (n= x y)
(not (= x y)))
(define (identity x) x)
(define (no-op x) x) ; guaranteed not to be in-lined
(define (null-list? x)
(cond ((null? x) #t)
((pair? x) #f)
(else
(assertion-violation 'null-list? "non-list" x))))
(define (reverse! l)
(cond ((or (null? l)
(null? (cdr l)))
l)
(else
(let ((rest (cdr l)))
(set-cdr! l '())
(let loop ((l1 l) (l2 rest))
(cond ((null? l2)
l1)
(else
(let ((rest (cdr l2)))
(set-cdr! l2 l1)
(loop l2 rest)))))))))
(define (memq? x l)
(let loop ((l l))
(cond ((null? l) #f)
((eq? x (car l)) #t)
(else (loop (cdr l))))))
(define (first pred list)
(let loop ((list list))
(cond ((null? list)
#f)
((pred (car list))
(car list))
(else
(loop (cdr list))))))
(define any first) ; ANY need not search in order, but it does anyway
(define (any? proc list)
(let loop ((list list))
(cond ((null? list)
#f)
((proc (car list))
#t)
(else
(loop (cdr list))))))
(define (every? pred list)
(let loop ((list list))
(cond ((null? list)
#t)
((pred (car list))
(loop (cdr list)))
(else
#f))))
(define (filter! pred list)
(let filter! ((list list))
(cond ((null-list? list)
'())
((pred (car list))
(set-cdr! list (filter! (cdr list))) list)
(else
(filter! (cdr list))))))
(define (filter-map f l)
(let loop ((l l) (r '()))
(cond ((null? l)
(reverse r))
((f (car l))
=> (lambda (x)
(loop (cdr l) (cons x r))))
(else
(loop (cdr l) r)))))
(define (remove-duplicates list)
(do ((list list (cdr list))
(res '() (if (memq? (car list) res)
res
(cons (car list) res))))
((null-list? list)
res)))
(define (partition-list pred l)
(let loop ((l l) (yes '()) (no '()))
(cond ((null? l)
(values (reverse yes) (reverse no)))
((pred (car l))
(loop (cdr l) (cons (car l) yes) no))
(else
(loop (cdr l) yes (cons (car l) no))))))
(define (partition-list! pred l)
(let loop ((l l) (yes '()) (no '()))
(cond ((null? l)
(values (reverse! yes) (reverse! no)))
((pred (car l))
(let ((rest (cdr l)))
(set-cdr! l yes)
(loop rest l no)))
(else
(let ((rest (cdr l)))
(set-cdr! l no)
(loop rest yes l))))))
(define (delq! object list)
(let loop ((list list))
(cond ((null? list)
'())
((eq? object (car list))
(loop (cdr list)))
(else
(let loop ((next (cdr list)) (prev list))
(cond ((null? next)
list)
((eq? (car next) object)
(set-cdr! prev (cdr next))
(loop (cdr next) prev))
(else
(loop (cdr next) next))))))))
(define (delq thing list)
(delete (lambda (x) (eq? x thing)) list))
(define (delete pred in-list)
(let loop ((list in-list) (res '()))
(cond ((null? list)
in-list)
((pred (car list))
(append-reverse! res (delete pred (cdr list))))
(else
(loop (cdr list) (cons (car list) res))))))
(define (append-reverse! l1 l2)
(let loop ((list l1) (res l2))
(cond ((null? list)
res)
(else
(let ((next (cdr list)))
(set-cdr! list res)
(loop next list))))))
; Copying strings.
(define (string->immutable-string string)
(if (immutable? string)
string
(let ((copy (string-copy string)))
(make-immutable! copy)
copy)))
|