2017-09-10

(sph)

bindings that are fundamental to all sph libraries.

mostly re-exports (rnrs base) and renamings

also adds the few aliases necessary to conform to the scheme syntax derivation of the standard language

part of sph-lib

highlights

debug-log

(debug-log 1 2 3) -> 1

this is like an identity function which also logs its arguments to standard output. only the first argument is the result

it can be inserted at many places to intercept the control flow without disturbing it

display-line

(display-line "test")

nullary

alternative to (lambda () body ...)

(call-with-values (nullary (partition a? b)) list)

let

simplified let syntax that works just like the original let but additionally supports binding just one variable

(let (a 1)
  body ...)

define-as

(define-as identifier list 1 2 3)
(define-as identifier (quote div) 1 2 3)
(define-as identifier ht-create-symbol a 1 b 2)

binds a value to identifier after applying arguments to the procedure or syntax-form given as the second argument.

the second argument can be a list of arbitrary length, which means the procedures or syntax-forms are composed. like for example (quote (div 1 2 3))

define-syntax-case

(define-syntax-case (test a b ...) s
  (syntax a))

(define-syntax-case (test a b ...)
  (syntax a))

(define-syntax-cases test
  ((test a b ...) (syntax a))
  ((test a b ...) (syntax a)))

the simplifications compared to syntax-case are

removes the possibility to define keywords

removes the possibility to use custom lambda for define-syntax

define-syntax-rule

(define-syntax-rule (test a b) (+ a b))

(define-syntax-rules test
  ((test a b) (+ a b))
  ((test a) a))

short-forms

l q qq
lambda quote quasiquote

list-q list-qq

(list-q a b c)
(list-qq a (unquote (+ 1 2)) c)

alternative to (quote (a b c))

(define-as list-q a b c)

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 from the first

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

quote-even

  any ... -> list

  quotes each second argument starting from 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)

import name

(sph)

exports

*

procedure

signature

[a b] c ... ->

+

procedure

signature

[a b] c ... ->

-

procedure

signature

[a b] c ... ->

/

procedure

signature

[a b] c ... ->

<

procedure

signature

[a b] c ... ->

<=

procedure

signature

[a b] c ... ->

=

procedure

signature

[a b] c ... ->

>

procedure

signature

[a b] c ... ->

>=

procedure

signature

[a b] c ... ->

abs

procedure

signature

a ->

acos

procedure

signature

a ->

and

syntax

and-let*

syntax

angle

procedure

signature

a ->

any

procedure

signature

pred ls lists ... ->

append

procedure

signature

a ... ->

append-map

procedure

signature

f clist1 rest ... ->

apply

procedure

signature

fun args ->

apply-values

syntax

signature

proc producer

asin

procedure

signature

a ->

atan

procedure

signature

a [b] ->

begin

syntax

boolean?

procedure

signature

a ->

call-with-current-continuation

procedure

signature

proc ->

call-with-values

procedure

signature

producer consumer ->

call/cc

procedure

case

syntax

ceiling

procedure

signature

a ->

char->integer

procedure

signature

a ->

char<=?

procedure

signature

[a b] c ... ->

char<?

procedure

signature

[a b] c ... ->

char=?

procedure

signature

[a b] c ... ->

char>=?

procedure

signature

[a b] c ... ->

char>?

procedure

signature

[a b] c ... ->

char?

procedure

signature

a ->

complex?

procedure

signature

a ->

compose-s

syntax

cond

syntax

cos

procedure

signature

a ->

datum->syntax

procedure

signature

id datum ->

debug-log

procedure

signature

a ... ->

any-1 any-n ... -> any-1

description

writes all arguments to standard output and returns the first argument

define

syntax

define*

syntax

define-as

syntax

signature

name (wrap-name ...) expr ...

define-syntax

syntax

define-syntax-case

syntax

signature

(name . pattern) syntax-name expansion

define-syntax-cases

syntax

signature

name ((pattern ...) expansion ...) ...

define-syntax-rule

syntax

signature

(name pattern ...) expansion

define-syntax-rules

syntax

signature

name ((pattern ...) expansion) ...

delete-duplicates

procedure

signature

a [b] ->

denominator

procedure

signature

a ->

display-line

procedure

signature

a [port] ->

any [port] -> unspecified

description

like "display" but emits a newline at the end

div

procedure

signature

a b ->

div-and-mod

procedure

signature

a b ->

div0

procedure

signature

a b ->

div0-and-mod0

procedure

signature

a b ->

dynamic-wind

procedure

signature

in thunk out ->

description

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

each

procedure

signature

f l ->

eq?

procedure

signature

[a b] c ... ->

equal?

procedure

signature

[a b] c ... ->

eqv?

procedure

signature

[a b] c ... ->

even?

procedure

signature

a ->

every

procedure

signature

pred ls lists ... ->

exact

procedure

signature

a ->

exact-integer-sqrt

procedure

signature

a ->

exact?

procedure

signature

a ->

exp

procedure

signature

a ->

expt

procedure

signature

a b ->

filter

procedure

signature

a b ->

filter-map

procedure

signature

proc list1 rest ... ->

description

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.

finite?

procedure

signature

a ->

first

procedure

signature

a ->

fold

procedure

signature

kons knil list1 ->

description

Apply PROC to the elements of LIST1 ... LISTN to build a result, and return

See the manual for details.

fold-right

procedure

signature

kons knil clist1 rest ... ->

for-each

procedure

signature

f l ->

gcd

procedure

signature

[a b] c ... ->

identifier-syntax

syntax

identifier?

procedure

signature

x ->

identity

procedure

signature

x ->

if

syntax

imag-part

procedure

signature

a ->

inexact

procedure

signature

a ->

inexact?

procedure

signature

a ->

infinite?

procedure

signature

a ->

integer->char

procedure

signature

a ->

integer-valued?

procedure

signature

x ->

integer?

procedure

signature

a ->

l

syntax

signature

a ...

l*

syntax

signature

a ...

lambda

syntax

lambda*

syntax

last

procedure

signature

pair ->

description

Return the last element of the non-empty, finite list PAIR.

lcm

procedure

signature

[a b] c ... ->

length

procedure

signature

a ->

let

syntax

signature

((variable-name expr) ...) body ...

let*

syntax

let-keywords

syntax

let-syntax

syntax

let-values

syntax

letrec

syntax

letrec*

syntax

letrec-syntax

syntax

list

procedure

signature

a ... ->

list->string

procedure

signature

a ->

list->vector

procedure

signature

a ->

list-ref

procedure

signature

a b ->

list-tail

procedure

signature

a b ->

list?

procedure

signature

a ->

log

procedure

signature

n ->

magnitude

procedure

signature

a ->

make-polar

procedure

signature

a b ->

make-rectangular

procedure

signature

a b ->

make-string

procedure

signature

a [b] ->

make-vector

procedure

signature

a [b] ->

map

procedure

signature

f l ->

max

procedure

signature

[a b] c ... ->

min

procedure

signature

[a b] c ... ->

mod

procedure

signature

a b ->

mod0

procedure

signature

a b ->

nan?

procedure

signature

a ->

negative?

procedure

signature

a ->

not

procedure

signature

a ->

null

variable

null?

procedure

signature

a ->

nullary

syntax

signature

body ...

number->string

procedure

signature

a [b] ->

number?

procedure

signature

a ->

numerator

procedure

signature

a ->

odd?

procedure

signature

a ->

or

syntax

pair

procedure

signature

a b ->

pair-fold

procedure

signature

kons knil clist1 rest ... ->

pair-fold-right

procedure

signature

kons knil clist1 rest ... ->

pair?

procedure

signature

a ->

pairs

procedure

signature

a b ... ->

positive?

procedure

signature

a ->

procedure?

procedure

signature

a ->

q

syntax

signature

a

qq

syntax

signature

a

quasiquote

syntax

quasisyntax

syntax

quote

syntax

quote-duplicate

syntax

signature

a

quote-even

syntax

quote-odd

syntax

rational-valued?

procedure

signature

x ->

rational?

procedure

signature

a ->

rationalize

procedure

signature

a b ->

real-part

procedure

signature

a ->

real-valued?

procedure

signature

x ->

real?

procedure

signature

a ->

remove

procedure

signature

a b ->

reverse

procedure

signature

a ->

round

procedure

signature

a ->

second

procedure

signature

a ->

sin

procedure

signature

a ->

sph-description

variable

sqrt

procedure

signature

a ->

string

procedure

signature

a ... ->

string->list

procedure

signature

a [b c] ->

string->number

procedure

signature

a [b] ->

string->symbol

procedure

signature

a ->

string-append

procedure

signature

a ... ->

string-copy

procedure

signature

a [b c] ->

string-length

procedure

signature

a ->

string-ref

procedure

signature

a b ->

string<=?

procedure

signature

[a b] c ... ->

string<?

procedure

signature

[a b] c ... ->

string=?

procedure

signature

[a b] c ... ->

string>=?

procedure

signature

[a b] c ... ->

string>?

procedure

signature

[a b] c ... ->

string?

procedure

signature

a ->

substring

procedure

signature

a b [c] ->

symbol->string

procedure

signature

a ->

symbol?

procedure

signature

a ->

syntax

syntax

syntax->datum

procedure

signature

x ->

syntax-rule

syntax

signature

(pattern ...) expansion

syntax-rules

syntax

syntax-rules_

syntax

signature

((pattern ...) expansion) ...

tail

procedure

signature

a ->

take-while

procedure

signature

pred ls ->

description

Return a new list which is the longest initial prefix of LS whose

elements all satisfy the predicate PRED.

tan

procedure

signature

a ->

truncate

procedure

signature

a ->

unquote

syntax

unquote-splicing

syntax

unsyntax

syntax

unsyntax-splicing

syntax

values

procedure

signature

a ... ->

vector

procedure

signature

a ... ->

vector->list

procedure

signature

a ->

vector-fill!

procedure

signature

a b ->

vector-for-each

procedure

signature

proc vecs ... ->

vector-length

procedure

signature

a ->

vector-map

procedure

signature

proc vecs ... ->

vector-ref

procedure

signature

a b ->

vector-set!

procedure

signature

a b c ->

vector?

procedure

signature

a ->

with-syntax

syntax

zero?

procedure

signature

a ->


tags: programming guile documentation library scheme sph-lib q1 sph highlight