2017-09-29

(sph two)

various bindings deemed less useful than the ones in (sph one)

part of sph-lib

import name

(sph two)

exports

alist->regexp-match-replacements

procedure

signature

a ->

description

automatically converts strings at the prefix position to regular expressions

and-p

procedure

signature

a ... ->

any -> false/any

description

like the "and" syntax but as a procedure

any-ht-keys->values

procedure

signature

ht a ->

r6rs-hashtable any -> any

description

replace the given value or values in a list with values in hashtable for the given value as key

any-ht-values->keys

procedure

signature

ht a ->

r6rs-hashtable any -> any

apply*

syntax

signature

arguments proc

apply-without-arguments

procedure

signature

procedure ->

bash-escape-clear

procedure

signature

->

description

display the bash escape sequence for clearing the screen - which usually means to scroll until the current line is at the top

begin-first-values

syntax

signature

a b ...

bindings-select-prefix

procedure

signature

prefix bindings-hash ->

string guile-hashtable -> (symbol ...)

description

return a list of binding names as symbols beginning with prefix

bindings-select-regexp

procedure

signature

regexp-str bindings-hash ->

string guile-hashtable -> (symbol ...)

description

return a list of binding names as symbols matching regexp

boolean->integer

procedure

signature

a ->

call

procedure

signature

proc a ... ->

procedure any ... -> any

description

apply procedure "proc" with arguments "a"

cons-if-not-included

procedure

signature

any lis [contain-proc] ->

description

add

copy-file!?

procedure

signature

source-path target-path ->

description

copy file source-path to target-path and check if target-path has the same size as source

copy-with-replaced-directory

procedure

signature

source-dir target-dir path ->

description

! depends on the cp

command. replace the source-dir portion in path with target-dir and copy the resulting path.

create-indent

procedure

signature

size ->

create-newline-indent

procedure

signature

size ->

create-quote

syntax

signature

a

debug-log-file

procedure

signature

a ... ->

description

writes all arguments in one line prefixed by the process id to an automatically created log file "/tmp/sph-scm-debug-log"

define-multiple

syntax

signature

() expr

define-stack-fluid

syntax

define-string

procedure

signature

name value ->

string any ->

description

define a variable by using a string for the name

define-syntax-identifier

syntax

signature

identifier expr

display-formatted

procedure

signature

#:port a ... ->

display-line*

procedure

signature

args ... ->

description

concatenate all given strings with spaces, add an newline and display

every-s

syntax

signature

proc a

generalised-length

procedure

signature

a ->

any -> integer

description

- count of digits for numbers

- number of chars for strings

- number of elements for lists

- false for anything else

generalised-less?

procedure

signature

a b ->

description

works for strings with string<, numbers with <, length with lists.

if numbers are compared with a string it takes the string representation of the number

get-filesystem-root

procedure

signature

path ->

string -> string

description

get the path to the root of the filesystem where path is pointing to, relative to the rootfs.

currently depends on procfs /proc/mounts

get-mime-extensions

procedure

signature

[path] ->

[string] -> (string ...)

description

get all filename extensions from "/etc/mime.types"

get-mime-extensions-cached

procedure

signature

a ... ->

guile-exception->string

procedure

signature

key a ... ->

symbol any ... -> string

description

create a space separated string from exception key and arguments.

uses "any->string" with the format of "display" to convert non-string arguments

hash-select

procedure

signature

proc bindings-hash ->

procedure guile-hashtable -> list

description

result in a list of bindings satisfying predicate proc

identity-s

syntax

signature

a

if-guile-exception

syntax

signature

expr consequent

let-if

syntax

signature

((variable-name expr) ...) true-expr false-expr

let-if*

syntax

line-reverse-direction

procedure

signature

line alt? c ->

string boolean procedure:{line boolean -> any} -> any

description

for the alternation of reading direction of lines.

it accounts for punctuation and parentheses and does not use utf-8 bidi capabilities.

calls "c" with a possibly word-reversed version of line and the new state for "alt?".

empty lines do not change the "alt?" state and are passed unchanged

list->create-list

syntax

signature

a

list->csv-line

procedure

signature

a ->

(string ...) -> string

description

converts list to a comma-separated line

list->nl-string

procedure

signature

a ->

list -> string

description

convert elements of list to a newline separated string

list->string-list

procedure

signature

a ->

(any ...) -> (string ...)

description

convert every element of a list to a string using the format display would use

list->values

procedure

signature

a ->

list-symbols->string

procedure

signature

a ->

list -> list

description

convert symbols in list to string

listener-on-port-local?

procedure

signature

port-number ->

integer -> boolean

description

probably system and linux dependent. checks using /proc/net/tcp if a process is listening on local network port port-number

md5sum

procedure

signature

a ->

string -> string:md5sum

description

get the md5sum of string by using the "md5sum" and "echo" program

md5sum-file

procedure

signature

path ->

string:path -> string:md5sum

description

get the md5sum of a file by using the "md5sum" program

move-and-link

procedure

signature

target-path source-path ->

string ... -> (boolean ...)

description

move source-path to target-path and replace original source-path

nl-string->list

procedure

signature

a ->

string -> (string ...)

description

split a string at newlines. empty lines are discarded

not-null?

procedure

signature

a ->

not-scm-file?

procedure

signature

file-path ->

string -> boolean

description

tests if a string has a .scm suffix

or-p

procedure

signature

a ... ->

any -> false/any

description

like the "or" syntax but as a procedure

os-seconds-at-boot

procedure

signature

->

os-seconds-since-boot

procedure

signature

->

path->symbol-list

procedure

signature

a ->

plaintext->shtml

procedure

signature

a ->

string -> list:sxml

description

convert double newlines to paragraphs <p> and single newlines to breaks <br>.

port-column-subtract!

procedure

signature

port integer ->

port-each-line-alternate-direction

procedure

signature

port proc ->

description

port procedure:{line ->}

alternates reading direction in lines read from port, with the exempt of lines

which do not only contain letters, digits or punctuation, which are passed as is.

it accounts for punctuation and parentheses and does not use utf-8 bidi capabilities

port-skip+count

procedure

signature

port skip-char ->

prefix-definition-names

syntax

prefix-imply-for

syntax

primitive-eval-port

procedure

signature

port ->

description

evaluate expressions from port until end of file is reached

process-unique-integer

procedure

signature

->

prog-sync-with-root

procedure

signature

source-root target-root on-error ->

description

string string procedure:{-> any}

take the first string from program-arguments and use it with copy-with-replaced-directory.

all exceptions are catched and on-error installed as a handler

read-line-crlf

procedure

signature

port ->

description

try to read a line that is known to be cr-lf terminated or return eof-object

read-line-crlf-trim

procedure

signature

port ->

description

try to read a line that is known to be cr-lf terminated and remove the cr-lf or return eof-object

read-mime.types

procedure

signature

path ->

string -> list:((string:type-name string:extension ...) ...)

description

read a mime.types file into a list. path is for example /etc/mime.types

seconds->short-kiloseconds-string

procedure

signature

a ->

set-multiple-from-list!

syntax

signature

() expr

sort-symbol-lists

procedure

signature

a ->

((symbol ...) ...) -> list

description

sort-module-names

sph-two-description

variable

srfi-19-date->seconds

procedure

signature

a ->

srfi-14-date -> integer unix-time-seconds

string-remove-leading-zeros

procedure

signature

a ->

string -> string

sxml->xml-string

procedure

signature

a ->

system-cat-merge-files

procedure

signature

include-list target-path [buffer-size] ->

(string:source-path ...) string:target-path integer -> string:target-path

list string -> string

description

take a list of file-paths and append them to a new file.

requires the "cat" program

system-path->mime-type

procedure

signature

path ->

string -> string

description

get the mime-type of a file by using the "file" program.

see also (sph libmagic) for a more efficient variant

system-realpath

procedure

signature

a ->

tail-symbols->string

procedure

signature

a ->

list -> list

description

convert all symbols not in prefix position to strings

values-bind

syntax

signature

producer lambda-formals body ...

variable-type

procedure

signature

a ->

any -> symbol

description

return a symbol indicating the variable type

variadic

syntax

signature

body ...

while-do

syntax

signature

expr proc stop-if

while-do-map

syntax

signature

expr proc stop-if

while-store

syntax

signature

expr stop-if

with-values

syntax

signature

producer proc


tags: programming guile documentation library scheme sph-lib two sph-two