Author: yamakenz
Date: Mon Apr 28 21:33:49 2008
New Revision: 5470
Modified:
trunk/scm/util.scm
Log:
* scm/util.scm
- Merge ustr modifications from the composer branch into trunk as
follows
$ svn merge -r951:HEAD
https://uim.googlecode.com/svn/branches/composer/scm/util.scm scm/util.scm
- (take-right): Remove the merged but obsolete one
----------------
r951 | yamaken | 2005-07-09 01:01:57 +0900 (Sat, 09 Jul 2005) | 7 lines
* scm/util.scm
- (sublist, sublist-rel): New procedure generalized from
utext-subtext and utext-subtext-rel
----------------
r968 | yamaken | 2005-07-12 20:26:53 +0900 (Tue, 12 Jul 2005) | 12 lines
* scm/util.scm
- (sublist-rel): Support -1 for len which means end of original lst
- (take-right): New SRFI procedure
----------------
r1109 | yamaken | 2005-08-03 09:57:13 +0900 (Wed, 03 Aug 2005) | 8 lines
* scm/util.scm
- (number->symbol, inc, dec, compensate-index): New procedure
Modified: trunk/scm/util.scm
==============================================================================
--- trunk/scm/util.scm (original)
+++ trunk/scm/util.scm Mon Apr 28 21:33:49 2008
@@ -64,6 +64,10 @@
(write s p)
(get-output-string p))))
+;; TODO: write test
+(define number->symbol
+ (compose string->symbol number->string))
+
;; procedural 'or' for use with 'apply'
;; e.g. (apply proc-or boolean-lst)
;; should be deprecated and replaced with a proper, Schemer's way
@@ -96,6 +100,21 @@
(take (drop lst start)
len)))
+;;; Merged from composer branch
+;;; TODO: Merge with trunk, write test
+;;;
+;;(define sublist
+;; (lambda (lst start end)
+;; (list-tail (list-head lst (+ end 1))
+;; start)))
+;;
+;;;; .parameter len Length to get. -1 means end of original lst
+;;(define sublist-rel
+;; (lambda (lst start len)
+;; (if (negative? len)
+;; (list-tail lst start)
+;; (sublist lst start (+ start len)))))
+
(define alist-replace
(lambda (kons alist)
(let* ((id (car kons))
@@ -176,6 +195,13 @@
(max bottom
(min x ceiling))))
+(define inc
+ (lambda (n)
+ (+ n 1)))
+
+(define dec
+ (lambda (n)
+ (- n 1)))
;;
;; uim-specific utilities
@@ -229,6 +255,17 @@
(- n 1))
(else
n))))
+
+;; TODO: write test
+;; Compensates an index number for an enumerable container
+;; .parameter idx Item index. Negative value instructs (abs idx)
+;; items before from last item
+;; .parameter size Size of the enumerable container
+(define compensate-index
+ (lambda (idx size)
+ (if (negative? idx)
+ (max 0 (+ size idx))
+ (clamp idx 0 (dec size)))))
;; update style-element vars
;; style-spec requires list of (style-element-name . validator)