1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-03 21:30:29 +02:00
guile/module/rnrs/base.scm
Andy Wingo e44d2e4d98 remove encoding of versions into the file system (for now?)
* module/ice-9/boot-9.scm (find-versioned-module): Remove. Still had
  some bugs (e.g. for "." in the path and in finding compiled files),
  did too much computation and statting, and we don't really want to
  promote versioning. Nor do we want to hard-code a particular encoding
  of versions in the file-system. Perhaps the real way to do this is to
  be extensible somehow.
  (try-module-autoload): Just dispatch to primitive-load-path in all cases.

* module/rnrs
* module/rnrs.scm:
* module/rnrs/arithmetic/bitwise.scm:
* module/rnrs/arithmetic/fixnums.scm:
* module/rnrs/arithmetic/flonums.scm:
* module/rnrs/base.scm:
* module/rnrs/conditions.scm:
* module/rnrs/control.scm:
* module/rnrs/enums.scm:
* module/rnrs/eval.scm:
* module/rnrs/exceptions.scm:
* module/rnrs/files.scm:
* module/rnrs/hashtables.scm:
* module/rnrs/io/simple.scm:
* module/rnrs/lists.scm:
* module/rnrs/mutable-pairs.scm:
* module/rnrs/mutable-strings.scm:
* module/rnrs/programs.scm:
* module/rnrs/r5rs.scm:
* module/rnrs/records/inspection.scm:
* module/rnrs/records/procedural.scm:
* module/rnrs/records/syntactic.scm:
* module/rnrs/sorting.scm:
* module/rnrs/syntax-case.scm:
* module/rnrs/unicode.scm: Move these files, eliding the "6/" infix, so
  that they are in the normal (unversioned) module path.
2010-06-16 22:20:28 +02:00

94 lines
3.2 KiB
Scheme
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;; base.scm --- The R6RS base library
;; Copyright (C) 2010 Free Software Foundation, Inc.
;;
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
;; License as published by the Free Software Foundation; either
;; version 3 of the License, or (at your option) any later version.
;;
;; This library is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Lesser General Public License for more details.
;;
;; You should have received a copy of the GNU Lesser General Public
;; License along with this library; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
(library (rnrs base (6))
(export boolean? symbol? char? vector? null? pair? number? string? procedure?
define define-syntax syntax-rules lambda let let* let-values
let*-values letrec begin
quote lambda if set! cond case
or and not
eqv? equal? eq?
+ - * / max min abs numerator denominator gcd lcm floor ceiling
truncate round rationalize real-part imag-part make-rectangular angle
div mod div-and-mod div0 mod0 div0-and-mod0
expt exact-integer-sqrt sqrt exp log sin cos tan asin acos atan
make-polar magnitude angle
complex? real? rational? integer? exact? inexact? real-valued?
rational-valued? integer-values? zero? positive? negative? odd? even?
nan? finite? infinite?
exact inexact = < > <= >=
number->string string->number
cons car cdr caar cadr cdar cddr caaar caadr cadar cdaar caddr cdadr
cddar cdddr caaaar caaadr caadar cadaar cdaaar cddaar cdadar cdaadr
cadadr caaddr caddar cadddr cdaddr cddadr cdddar cddddr
list? list length append reverse list-tail list-ref map for-each
symbol->string string->symbol symbol=?
char->integer integer->char char=? char<? char>? char<=? char>=?
make-string string string-length string-ref string=? string<? string>?
string<=? string>=? substring string-append string->list list->string
string-for-each string-copy
vector? make-vector vector vector-length vector-ref vector-set!
vector->list list->vector vector-fill! vector-map vector-for-each
error assertion-violation assert
call-with-current-continuation call/cc call-with-values dynamic-wind
values apply
quasiquote unquote unquote-splicing
let-syntax letrec-syntax
syntax-rules identifier-syntax)
(import (rename (guile) (quotient div) (modulo mod))
(rename (only (guile) for-each map)
(for-each vector-for-each) (map vector-map))
(srfi srfi-11))
(define (div-and-mod x y) (let ((q (div x y)) (r (mod x y))) (values q r)))
(define (div0 x y)
(call-with-values (lambda () (div0-and-mod0 x y)) (lambda (q r) q)))
(define (mod0 x y)
(call-with-values (lambda () (div0-and-mod0 x y)) (lambda (q r) r)))
(define (div0-and-mod0 x y)
(call-with-values (lambda () (div-and-mod x y))
(lambda (q r)
(cond ((< r (abs (/ y 2))) (values q r))
((negative? y) (values (- q 1) (+ r y)))
(else (values (+ q 1) (+ r y)))))))
)