From e5d0cc1c9f409827de95c9aeede8b4ae0c014d2c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 7 Apr 2012 10:24:01 -0700 Subject: * txr.1: Documented int-flo, flo-int, search-regex, match-regex and regsub. --- ChangeLog | 5 +++++ txr.1 | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/ChangeLog b/ChangeLog index 325a6edb..0413e9a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-04-07 Kaz Kylheku + + * txr.1: Documented int-flo, flo-int, search-regex, + match-regex and regsub. + 2012-04-07 Kaz Kylheku Rounding out hash table functionality with lazy lists that diff --git a/txr.1 b/txr.1 index b3277021..09db9309 100644 --- a/txr.1 +++ b/txr.1 @@ -7198,10 +7198,82 @@ followed by a period, e or E. .SS Functions int-flo and flo-int +.TP +Syntax: + + (int-flo ) + (flo-int ) + +.TP +Description: + +These functions perform numeric conversion between integer and floating point +type. The int-flo function returns an integer by truncating toward zero. +The flo-int function returns an exact floating point value corresponding to the +integer argument, if possible, otherwise an approximation using a nearby +floating point value. + .SS Functions search-regex and match-regex +.TP +Syntax: + + (search-regex : ) + (match-regex : ) + +.TP +Description + +These functions perform regular-expression-based searching and matching. + +The search-regex function searches through starting +at position for a match for . If is omitted, +the search starts at position 0. If is specified, the search +proceeds in reverse, from the last position in the string, toward . +This function returns nil if no match is found, otherwise it returns +a cons pair, whose car indicates the position of the match, and whose +cdr indicates the length of the match. + +The match-regex function tests whether matches at +in . If is not specified, it is taken to be zero. +If the regex matches, then the length of the match is returned. +If it does not match, then nil is returned. +. .SS Function regsub +.TP +Syntax: + + (regsub ) + +.TP +Description: + +The regsub function searches for multiple occurences of +non-overlapping matches for . A new string is constructed +similar to but in which each matching region is replaced +with using as follows. + +The object may be a character or a string, in which +case it is simply taken to be the replacement for each match +of the regular expression. + +The object may be a function of one argument, in +which case for every match which is found, this function is invoked, +with the matching piece of text as an argument. The function's +return value is then taken to be the replacement text. + +.TP +Examples: + + ;; match every lower case e or o, and replace by filtering + ;; through the upcase-str function: + + [regsub #/[eo]/ upcase-str "Hello world!"] -> "HEllO wOrld!" + + ;; Replace Hello with Goodbye: + (regsub #/Hello/ "Goodbye" "Hello world!") -> "Goodbye world!" + .SS Functions make-hash, hash .SS Function sethash -- cgit v1.2.3