summaryrefslogtreecommitdiff
path: root/module/rnrs/base.scm
AgeCommit message (Collapse)AuthorFilesLines
2021-03-09Write a proper vector-map and vector-for-each for (rnrs base)Linus1-5/+76
* module/rnrs/base.scm (vector-map vector-for-each): Rewrite to not be slow. * NEWS: Update.
2019-09-12Define top-level bindings for aux syntax: else, =>, _, ...Andy Wingo1-2/+2
* module/ice-9/boot-9.scm (else, =>, ..., _): New definitions. These are specified by the r6rs and the r7rs. * module/ice-9/sandbox.scm (core-bindings): Include the aux syntax definitions. * module/rnrs/base.scm: * module/rnrs.scm: Re-export aux syntax.
2012-11-22R6RS `string-for-each' should accept multiple string argumentsIan Price1-1/+38
* module/rnrs/base.scm (string-for-each): Rewrite. * test-suite/tests/r6rs-base.test ("string-for-each"): Add tests.
2011-08-17fix r6rs `map'Andy Wingo1-1/+71
* module/rnrs/base.scm (map): Define a version of map that is safe for multiple returns, though slower.
2011-04-11fix assert to return true value.Ian Price1-1/+1
* module/rnrs/base.scm (assert): returns value instead of void. * test-suite/tests/r6rs-base.test ("assert"): add test cases.
2011-04-11Added optional second arg to R6RS log functionIan Price1-0/+9
* module/rnrs/base.scm (log): now takes a base argument, using the change of base formula for logs. * test-suite/tests/r6rs-base.test ("log (2nd arg)"): Add test cases.
2011-04-09Fix the R6RS exact-integer-sqrt and import into core guileMark H Weaver1-3/+0
* libguile/numbers.c (scm_exact_integer_sqrt): New C procedure to compute exact integer square root and remainder. (scm_i_exact_integer_sqrt): New Scheme procedure `exact-integer-sqrt' from the R6RS, imported into core guile. * libguile/numbers.h: Add prototypes. * module/rnrs/base.scm: Remove broken stub implementation, which would fail badly when applied to large integers. * doc/ref/api-data.texi: Add documentation. * doc/ref/r6rs.texi: Change documentation for `exact-integer-sqrt' to a stub that xrefs the core docs, as is done for other operations available in core. * test-suite/tests/numbers.test: Add tests. * NEWS: Add news entries.
2011-02-22Make `(rnrs base)' independent of other rnrs modules.Ludovic Courtès1-13/+22
* module/rnrs/base.scm (define-proxy): New macro. (raise, condition, make-error, make-assertion-violation, make-who-condition, make-message-condition, make-irritants-condition): Use it.
2011-02-02Avoid circular dependency between (rnrs base) and (rnrs exceptions).Ludovic Courtès1-2/+7
* module/rnrs/base.scm (raise): Define as a macro instead of a procedure.
2011-01-30Add two new sets of fast quotient and remainder operatorsMark H Weaver1-17/+6
* libguile/numbers.c (scm_euclidean_quo_and_rem, scm_euclidean_quotient, scm_euclidean_remainder, scm_centered_quo_and_rem, scm_centered_quotient, scm_centered_remainder): New extensible procedures `euclidean/', `euclidean-quotient', `euclidean-remainder', `centered/', `centered-quotient', `centered-remainder'. * libguile/numbers.h: Add function prototypes. * module/rnrs/base.scm: Remove incorrect stub implementations of `div', `mod', `div-and-mod', `div0', `mod0', and `div0-and-mod0'. Instead do renaming imports of `euclidean-quotient', `euclidean-remainder', `euclidean/', `centered-quotient', `centered-remainder', and `centered/', which are equivalent to the R6RS operators. * module/rnrs/arithmetic/fixnums.scm (fxdiv, fxmod, fxdiv-and-mod, fxdiv0, fxmod0, fxdiv0-and-mod0): Remove redundant checks for division by zero and unnecessary complexity. (fx+/carry): Remove unneeded calls to `inexact->exact'. * module/rnrs/arithmetic/flonums.scm (fldiv, flmod, fldiv-and-mod, fldiv0, flmod0, fldiv0-and-mod0): Remove redundant checks for division by zero and unnecessary complexity. Remove unneeded calls to `inexact->exact' and `exact->inexact' * test-suite/tests/numbers.test: (test-eqv?): New internal predicate for comparing numerical outputs with expected values. Add extensive test code for `euclidean/', `euclidean-quotient', `euclidean-remainder', `centered/', `centered-quotient', `centered-remainder'. * test-suite/tests/r6rs-arithmetic-fixnums.test: Fix some broken test cases, and remove `unresolved' test markers for `fxdiv', `fxmod', `fxdiv-and-mod', `fxdiv0', `fxmod0', and `fxdiv0-and-mod0'. * test-suite/tests/r6rs-arithmetic-flonums.test: Remove `unresolved' test markers for `fldiv', `flmod', `fldiv-and-mod', `fldiv0', `flmod0', and `fldiv0-and-mod0'. * doc/ref/api-data.texi (Arithmetic): Document `euclidean/', `euclidean-quotient', `euclidean-remainder', `centered/', `centered-quotient', and `centered-remainder'. (Operations on Integer Values): Add cross-references to `euclidean/' et al, from `quotient', `remainder', and `modulo'. * doc/ref/r6rs.texi (rnrs base): Improve documentation for `div', `mod', `div-and-mod', `div0', `mod0', and `div0-and-mod0'. Add cross-references to `euclidean/' et al. * NEWS: Add NEWS entry.
2011-01-30Implement R6RS `real-valued?', `rational-valued?', `integer-valued?'Mark H Weaver1-8/+11
* module/rnrs/base.scm (real-valued?, rational-valued?, integer-valued?): Implement in compliance with R6RS. * test-suite/tests/r6rs-base.test: Add test cases for `real-valued?', `rational-valued?', and `integer-valued?'. * NEWS: Add NEWS entries.
2011-01-28Implement `finite?' in core and fix R6RS `finite?' and `infinite?'Mark H Weaver1-4/+2
* libguile/numbers.c (scm_finite_p): Add new predicate `finite?' from R6RS to guile core, which returns #t if and only if its argument is neither infinite nor a NaN. Note that this is not the same as (not (inf? x)) or (not (infinite? x)), since NaNs are neither finite nor infinite. * test-suite/tests/numbers.test: Add test cases for `finite?'. * module/rnrs/base.scm: Import `inf?' as `infinite?' instead of reimplementing it. Previously, the R6RS implementation of `infinite?' did not detect non-real complex infinities, nor did it throw exceptions for non-numbers. (Note that NaNs _are_ considered numbers by scheme, despite their name). Import `finite?' instead of reimplementing it. Previously, the R6RS implementation of `finite?' returned #t for both NaNs and non-real complex infinities, in violation of R6RS. * NEWS: Add NEWS entries, and reorganize existing numerics-related entries together under one subheading. * doc/ref/api-data.texi (Real and Rational Numbers): Add docs for `finite?' and scm_finite_p.
2010-11-25Some tweaks to the R6RS supportAndreas Rottmann1-6/+24
* module/rnrs/base.scm (error, assert): Define -- they were missing. (assertion-violation): Properly treat a #f `who' argument. * module/rnrs/conditions.scm (condition): Use `assertion-violation' instead of the undefined `raise'. (define-condition-type): Fix for multiple fields. * test-suite/tests/r6rs-conditions.test: Test accessors of a multiple-field condition. Also import `(rnrs base)' to allow stand-alone running of the tests; apparently the `@' references scattered throughout the R6RS modules make the libraries sensitive to their load order -- for instance, trying to load `(rnrs conditions)' before `(rnrs base)' is loaded fails. * module/rnrs/records/inspection.scm: Use `assertion-violation' instead of an explicit `raise'. * module/rnrs/records/syntactic.scm (process-fields): Use `syntax-violation' instead of bogus invocations of `error'.
2010-11-17Add exports for missing functions from `(rnrs base)'.Julian Graham1-3/+42
* module/rnrs.scm (boolean=?): New export. Fix typo in export of`integer-valued?'. * module/rnrs/base.scm: Add exports for `exact' and `inexact'. (boolean=?, symbol=?, infinite?, finite?, exact-integer-sqrt, integer-valued?, rational-valued?, real-valued?): New functions. * test-suite/tests/r6rs-base.test (boolean=?, symbol=?, infinite?, finite?, exact-integer-sqrt, integer-valued?, rational-valued?, real-valued?): New test prefixes and tests.
2010-08-28Several fixes to R6RS librariesAndreas Rottmann1-0/+20
* module/rnrs/arithmetic/fixnums.scm (fixnum-width): Make this return an an exact integer instead of an inexact number. * module/rnrs/base.scm (assertion-violation): Implement. * module/rnrs/conditions.scm (simple-conditions): Allow also simple conditions as argument. * module/rnrs/enums.scm (define-enumeration): Properly construct empty enumeration sets. * module/rnrs/exceptions.scm (guard): Don't restrict the body to a single expression. * module/rnrs/records/syntactic.scm (define-record-type0): Expand into a series of definitions only.
2010-08-08Explicit definitions for `vector-for-each' and `vector-map'; Guile's SRFI-1Julian Graham1-2/+5
`for-each' and `map' implementations do not operate on lists and vectors interchangeably. * module/rnrs/base.scm (vector-for-each, vector-map): New functions. * test-suite/Makefile.am: Add test-suite/tests/r6rs-base.test to SCM_TESTS. * test-suite/tests/r6rs-base.test: New file.
2010-08-06letrec* in docs, and some r6rs fixesAndy Wingo1-1/+1
* doc/ref/api-binding.texi: Add docs for letrec*, and revise some other text. * doc/ref/compiler.texi: Update <letrec> for in-order?. * doc/ref/r6rs.texi: Add letrec* entry. * module/rnrs.scm: * module/rnrs/base.scm: Export letrec*.
2010-06-16remove encoding of versions into the file system (for now?)Andy Wingo1-0/+94
* 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.