2019-04-20

(sph)

bindings that are fundamental to all sph libraries.

part of sph-lib

library description

exports (rnrs base) except set!. if you need set!, import it with (import (only (rnrs base) set!))

# syntax

quote-odd

  any ... -> list

  quotes each second argument starting with the first

  example: a b c d -> ((quote a) b (quote c) d)

quote-even

  any ... -> list

  quotes each second argument starting with the second

  example: a b c d -> (a (quote b) c (quote d))

quote-duplicate

  any ... -> list

  create two elements from each identifier: one the literal identifier symbol,

  the other the value of the variable bound to identifier.

  example: a b c -> ((quote a) a (quote b) b (quote c) c)

  example 2

    (let ((a 1) (b 2) (c 3)) (quote-duplicate a b c))

    -> (list a 1 b 2 c 3)

define-as

  example: (define-as list 1 2 3)

  example: (define-as (quasiquote list) 1 (unquote 3))

compose-s

  (compose-s a (list 1 2)) -> (a (list 1 2))

  (compose-s (a b) (list 1 2)) -> (a (b (list 1 2)))

  this does not fail in the case (_ (quasiquote list) expr ...)

nullary

  create a procedure that accepts zero arguments and evaluates body when called.

  often used for thunks

let

  typical scheme let and named-let extended with a simplified syntax for binding just one variable

  example: (let (a 3) a)

list-q list-qq

  list-q :: any ...

  list-qq :: any ...

  same as (quote (a ...)) or (quasiquote (a ...))

  example: (list-q a b c)

import name

(sph)

exports

procedure: * [a b] c ... ->
procedure: + [a b] c ... ->
procedure: - [a b] c ... ->
procedure: / [a b] c ... ->
procedure: < [a b] c ... ->
procedure: <= [a b] c ... ->
procedure: = [a b] c ... ->
procedure: > [a b] c ... ->
procedure: >= [a b] c ... ->
procedure: abs a ->
procedure: acos a ->
syntax: and
syntax: and-let*
procedure: angle a ->
procedure: any pred ls lists ... ->
procedure: append a ... ->
procedure: append-map f clist1 rest ... ->
procedure: apply fun args ->
syntax: apply-values proc producer
procedure: asin a ->
procedure: atan a [b] ->
syntax: begin
procedure: boolean? a ->
procedure: call-with-current-continuation proc ->
procedure: call-with-values producer consumer ->
procedure: call/cc
syntax: case
procedure: ceiling a ->
procedure: char->integer a ->
procedure: char<=? [a b] c ... ->
procedure: char<? [a b] c ... ->
procedure: char=? [a b] c ... ->
procedure: char>=? [a b] c ... ->
procedure: char>? [a b] c ... ->
procedure: char? a ->
procedure: complex? a ->
syntax: compose-s
syntax: cond
procedure: cos a ->
procedure: datum->syntax id datum ->
procedure: debug-log a ... ->
any-1 any-n ... -> any-1
writes all arguments to standard output and returns the first argument
syntax: define
syntax: define*
syntax: define-as name (wrap-name ...) expr ...
syntax: define-syntax
syntax: define-syntax-case (name . pattern) syntax-name expansion
syntax: define-syntax-cases name ((pattern ...) expansion ...) ...
syntax: define-syntax-rule (name pattern ...) expansion
syntax: define-syntax-rules name ((pattern ...) expansion) ...
procedure: delete-duplicates a [b] ->
procedure: denominator a ->
procedure: display-line a [port] ->
any [port] -> unspecified
like "display" but emits a newline at the end
procedure: div a b ->
procedure: div-and-mod a b ->
procedure: div0 a b ->
procedure: div0-and-mod0 a b ->
procedure: dynamic-wind in thunk out ->
All three arguments must be 0-argument procedures.
If the continuation of
the dynamic-wind is re-entered, @var{in} is called. Thus
@var{in} and @var{out} may be called any number of
times.
@lisp
(define x 'normal-binding)
@result{} x
(define a-cont
(call-with-current-continuation
(lambda (escape)
(let ((old-x x))
(dynamic-wind
;; in-guard:
;;
(lambda () (set! x 'special-binding))

;; thunk
;;
(lambda () (display x) (newline)
(call-with-current-continuation escape)
(display x) (newline)
x)

;; out-guard:
;;
(lambda () (set! x old-x)))))))

;; Prints:
special-binding
;; Evaluates to:
@result{} a-cont
x
@result{} normal-binding
(a-cont #f)
;; Prints:
special-binding
;; Evaluates to:
@result{} a-cont ;; the value of the (define a-cont...)
x
@result{} normal-binding
a-cont
@result{} special-binding
@end lisp
procedure: each f l ->
procedure: eq? [a b] c ... ->
procedure: equal? [a b] c ... ->
procedure: eqv? [a b] c ... ->
procedure: even? a ->
procedure: every pred ls lists ... ->
procedure: exact a ->
procedure: exact-integer-sqrt a ->
procedure: exact? a ->
procedure: exp a ->
procedure: expt a b ->
procedure: filter a b ->
procedure: filter-map proc list1 rest ... ->
Apply PROC to the elements of LIST1... and return a list of the
results as per SRFI-1 `map', except that any #f results are omitted from
the list returned.
procedure: finite? a ->
procedure: first a ->
procedure: fold kons knil list1 ->
Apply PROC to the elements of LIST1 ... LISTN to build a result, and return
See the manual for details.
procedure: fold-right kons knil clist1 rest ... ->
procedure: for-each f l ->
procedure: gcd [a b] c ... ->
syntax: identifier-syntax
procedure: identifier? x ->
procedure: identity x ->
syntax: if
procedure: imag-part a ->
procedure: inexact a ->
procedure: inexact? a ->
procedure: infinite? a ->
procedure: integer->char a ->
procedure: integer-valued? x ->
procedure: integer? a ->
syntax: l a ...
syntax: l* a ...
syntax: lambda
syntax: lambda*
procedure: last pair ->
Return the last element of the non-empty, finite list PAIR.
procedure: lcm [a b] c ... ->
procedure: length a ->
syntax: let ((variable-name expr) ...) body ...
syntax: let*
syntax: let-keywords
syntax: let-syntax
syntax: let-values
syntax: letrec
syntax: letrec*
syntax: letrec-syntax
procedure: list a ... ->
procedure: list->string a ->
procedure: list->vector a ->
syntax: list-q a ...
syntax: list-qq a ...
procedure: list-ref a b ->
procedure: list-tail a b ->
procedure: list? a ->
procedure: log n ->
procedure: magnitude a ->
procedure: make-polar a b ->
procedure: make-rectangular a b ->
procedure: make-string a [b] ->
procedure: make-vector a [b] ->
procedure: map f l ->
procedure: max [a b] c ... ->
procedure: min [a b] c ... ->
procedure: mod a b ->
procedure: mod0 a b ->
procedure: nan? a ->
procedure: negative? a ->
procedure: not a ->
variable: null
procedure: null? a ->
syntax: nullary body ...
procedure: number->string a [b] ->
procedure: number? a ->
procedure: numerator a ->
procedure: odd? a ->
syntax: or
procedure: pair a b ->
procedure: pair-fold kons knil clist1 rest ... ->
procedure: pair-fold-right kons knil clist1 rest ... ->
procedure: pair? a ->
procedure: pairs a b ... ->
procedure: positive? a ->
procedure: procedure? a ->
syntax: q a
syntax: qq a
syntax: quasiquote
syntax: quasisyntax
syntax: quote
syntax: quote-duplicate a
syntax: quote-even
syntax: quote-odd
procedure: rational-valued? x ->
procedure: rational? a ->
procedure: rationalize a b ->
procedure: real-part a ->
procedure: real-valued? x ->
procedure: real? a ->
procedure: remove a b ->
procedure: reverse a ->
procedure: round a ->
procedure: second a ->
procedure: sin a ->
variable: sph-description
procedure: sqrt a ->
procedure: string a ... ->
procedure: string->list a [b c] ->
procedure: string->number a [b] ->
procedure: string->symbol a ->
procedure: string-append a ... ->
procedure: string-copy a [b c] ->
procedure: string-length a ->
procedure: string-ref a b ->
procedure: string<=? [a b] c ... ->
procedure: string<? [a b] c ... ->
procedure: string=? [a b] c ... ->
procedure: string>=? [a b] c ... ->
procedure: string>? [a b] c ... ->
procedure: string? a ->
procedure: substring a b [c] ->
procedure: symbol->string a ->
procedure: symbol? a ->
syntax: syntax
procedure: syntax->datum x ->
syntax: syntax-rule (pattern ...) expansion
syntax: syntax-rules
syntax: syntax-rules_ ((pattern ...) expansion) ...
procedure: tail a ->
procedure: take-while pred ls ->
Return a new list which is the longest initial prefix of LS whose
elements all satisfy the predicate PRED.
procedure: tan a ->
procedure: third a ->
procedure: truncate a ->
syntax: unquote
syntax: unquote-splicing
syntax: unsyntax
syntax: unsyntax-splicing
procedure: values a ... ->
procedure: vector a ... ->
procedure: vector->list a ->
procedure: vector-fill! a b ->
procedure: vector-for-each proc vecs ... ->
procedure: vector-length a ->
procedure: vector-map proc vecs ... ->
procedure: vector-ref a b ->
procedure: vector-set! a b c ->
procedure: vector? a ->
syntax: with-syntax
procedure: zero? a ->