diff options
Diffstat (limited to 'doc/ref/guile/util.texi')
-rw-r--r-- | doc/ref/guile/util.texi | 62 |
1 files changed, 58 insertions, 4 deletions
diff --git a/doc/ref/guile/util.texi b/doc/ref/guile/util.texi index 32df5fce..1d35e0bf 100644 --- a/doc/ref/guile/util.texi +++ b/doc/ref/guile/util.texi @@ -113,6 +113,11 @@ See @var{find-extreme} @end lisp @end defun +@defun init+last list +Returns two values: everything except the last element of @var{list}, +and the last element of @var{list}. +@end defun + @defun take-to lst n Equivalent to @var{take}, but return everything (instead of crash) if n > (length lst). @@ -175,8 +180,8 @@ pairs of symbols and values. @lisp (kvlist->assq '(#:a 1 #:b "Hello")) -⇒ ((a 1) - (b "Hello")) +⇒ ((a . 1) + (b . "Hello")) @end lisp @end defun @@ -188,6 +193,8 @@ pairs of symbols and values. Calls @var{proc} on each element in @var{lst}, and return a association list which @code{(proc e)} as its keys, and all elements which mapped to that value. + +The values returned by @var{proc} are compared as per @code{equal?}. @end defun @defun split-by lst element @@ -219,7 +226,9 @@ list, whose indices matches the order of the inputs @end defun @defun string-flatten tree -@c TODO document me +Given an arbitary tree, do a pre-order traversal, appending all strings. + +Non-strings are converted to strings, and also appended. @end defun @defun intersperse item list @@ -227,7 +236,7 @@ Inserts @var{item} between each element in @var{list}. @end defun -@defun insert-ordered item collection [<=<] +@defun insert-ordered item collection [<] Inserts @var{item} into @var{collection}, such that collection remainins sorted if it was sorted beforehand. @end defun @@ -315,10 +324,18 @@ Similar to @var{let}, but sets environment variables for the code in body. Restores the old values once we leave. @end defmac +@defmac with-locale1 category locale thunk +Run @var{thunk} with the locale @var{category} temporarily set to +@var{locale}. +@end defmac + @defmac catch* thunk (symbol proc) ... Macro allowing multiple exception types to be caught. Each (symbol proc) pair expands to a regular @code{catch}, with the leftmost being innermost. + +@var{Symbol} can also be on the form @code{(pre-unwind @var{symbol})}, +then @code{with-throw-handler} is used instead of @code{catch}. @end defmac @subsection UUID generation @@ -332,3 +349,40 @@ Generates a UUID-v4 string. @defun uuid Generates an implementation defined (but guaranteed valid) UUID. @end defun + +@subsection IO + +Provided by module @code{(hnh util io)}. + +@defun open-input-port path +@defunx open-output-port path +Like @code{open-*-file}, but ``-'' gives @code{standard-@{input,output@}}. +@end defun + +@defun read-lines port +Return a list of all lines read from port. +@end defun + +@defun with-atomic-output-to-file filename thunk +Same functionality as the regular @var{with-output-to-file}, but +with the difference that either everything is written, or nothing +is written, and if anything is written it's all written atomicaly at +once (the original file will never contain an intermidiate state). +Does NOT handle race conditions between threads. + +propagates the return value of @var{thunk} upon successfully writing +the file, and @code{#f} otherwise. +@end defun + +@defun call-with-tmpfile proc [#:tmpl ``/tmp/file-XXXXXXX''] +@end defun + +@defun ->port port-or-strings +If @var{port-or-string} is a port, return it directly. If it's a +string, instead return an input string containing the strings content. +@end defun + +@c Is this even a procedure? +@defun read-file path +Open file at path, and return its content as a string. +@end defun |