set module version in module-export-all!
[bpt/guile.git] / module / rnrs / 6 / base.scm
1 ;;; base.scm --- The R6RS base library
2
3 ;; Copyright (C) 2010 Free Software Foundation, Inc.
4 ;;
5 ;; This library is free software; you can redistribute it and/or
6 ;; modify it under the terms of the GNU Lesser General Public
7 ;; License as published by the Free Software Foundation; either
8 ;; version 3 of the License, or (at your option) any later version.
9 ;;
10 ;; This library is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ;; Lesser General Public License for more details.
14 ;;
15 ;; You should have received a copy of the GNU Lesser General Public
16 ;; License along with this library; if not, write to the Free Software
17 ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 \f
19
20 (library (rnrs base (6))
21 (export boolean? symbol? char? vector? null? pair? number? string? procedure?
22
23 define define-syntax syntax-rules lambda let let* let-values
24 let*-values letrec begin
25
26 quote lambda if set! cond case
27
28 or and not
29
30 eqv? equal? eq?
31
32 + - * / max min abs numerator denominator gcd lcm floor ceiling
33 truncate round rationalize real-part imag-part make-rectangular angle
34 div mod div-and-mod div0 mod0 div0-and-mod0
35
36 expt exact-integer-sqrt sqrt exp log sin cos tan asin acos atan
37 make-polar magnitude angle
38
39 complex? real? rational? integer? exact? inexact? real-valued?
40 rational-valued? integer-values? zero? positive? negative? odd? even?
41 nan? finite? infinite?
42
43 exact inexact = < > <= >=
44
45 number->string string->number
46
47 cons car cdr caar cadr cdar cddr caaar caadr cadar cdaar caddr cdadr
48 cddar cdddr caaaar caaadr caadar cadaar cdaaar cddaar cdadar cdaadr
49 cadadr caaddr caddar cadddr cdaddr cddadr cdddar cddddr
50
51 list? list length append reverse list-tail list-ref map for-each
52
53 symbol->string string->symbol symbol=?
54
55 char->integer integer->char char=? char<? char>? char<=? char>=?
56
57 make-string string string-length string-ref string=? string<? string>?
58 string<=? string>=? substring string-append string->list list->string
59 string-for-each string-copy
60
61 vector? make-vector vector vector-length vector-ref vector-set!
62 vector->list list->vector vector-fill! vector-map vector-for-each
63
64 error assertion-violation assert
65
66 call-with-current-continuation call/cc call-with-values dynamic-wind
67 values apply
68
69 quasiquote unquote unquote-splicing
70
71 let-syntax letrec-syntax
72
73 syntax-rules identifier-syntax)
74 (import (rename (guile) (quotient div) (modulo mod))
75 (rename (only (guile) for-each map)
76 (for-each vector-for-each) (map vector-map))
77 (srfi srfi-11))
78
79 (define (div-and-mod x y) (let ((q (div x y)) (r (mod x y))) (values q r)))
80
81 (define (div0 x y)
82 (call-with-values (lambda () (div0-and-mod0 x y)) (lambda (q r) q)))
83
84 (define (mod0 x y)
85 (call-with-values (lambda () (div0-and-mod0 x y)) (lambda (q r) r)))
86
87 (define (div0-and-mod0 x y)
88 (call-with-values (lambda () (div-and-mod x y))
89 (lambda (q r)
90 (cond ((< r (abs (/ y 2))) (values q r))
91 ((negative? y) (values (- q 1) (+ r y)))
92 (else (values (+ q 1) (+ r y)))))))
93
94 )