edward.util

This library provides various generic utility procedures.

Index

Table of contents

String Procedures

Utility procedures which operate on strings.

procedure empty-string?

Return true if the given string str is the empty string.

(empty-string? str)

procedure pad-string

Pad given string str with given padding string pad to length.

(pad-string str pad length)

procedure string->human-readable

Convert string to a human readable representation as mandated by the ed list command.

(string->human-readable str)

procedure path-join

Join a list of path elements (i.e. strings) using / as a path separator.

(path-join . elems)

procedure count-bytes

Return amount of bytes in a string.

(count-bytes str)

procedure lines->string

Converts list of lines to newline-separated string.

(lines->string buffer)

IO Procedures

Procedures which deal with input/output.

procedure write-file

Write given data to a given file, returns #t if write was successful, #f otherwise. If the file doesn't exist it is created, otherwise it is truncated.

(write-file filename data)

procedure port->lines

Read from given port as a list of lines. Returns pair of retrieved lines and total amount of bytes read from the port (including newlines).

(port->lines port)

Miscellaneous

Miscellaneous utility procedures.

procedure inc

Syntactic sugar to increment a number by one.

(inc n)

procedure dec

Syntactic sugar to decrement a number by one.

(dec n)

procedure id

Identity function, always returns the given value.

(id x)

procedure alist-values

Returns all values of an alist, discarding the keys.

(alist-values alist)

procedure println

Like display but prints multiple objects and adds a trailing newline.

(println . objs)

procedure fprintln

Like println but allows specification of a custom output port.

(fprintln port . objs)

procedure for-each-index

Call proc for each element in lst starting at the start index. For each element, the procedure proc is passed both the index as well as the element value itself as a procedure parameter.

(for-each-index proc cont-proc lst start)

procedure sublist

Return sublist with start inclusive and end exclusive.

(sublist lst start end)

procedure user-home

Return path to home directory of current user. This procedure emits an error if the environment variable HOME is unset.

(user-home)