List() command: extends capabilities
I propose to extend command list()
by adding various new sub-commands.
Before starting implementation, I need feed-back about these propositions. I sorted them by importance (most important/useful first) from my point of view.
-
SUBLIST
: to extract a sub-list from a list.
# list (SUBLIST <list> <start> <length> <output variable>)
set (mylist a b c d)
list (SUBLIST mylist 1 -1 sublist)
# result: b c d
-
CONCAT
: To concatenate aPREFIX
or aSUFFIX
to each list's elements.
# list (CONCAT <list> <PREFIX|SUFFIX> <value>)
set (dirs dir1 dir2)
list (CONCAT dirs PREFIX "/root/")
# result: /root/dir1 /root/dir2
-
INSERT
: To insert,BEFORE
orAFTER
each list's elements a new value.
# list (INSERT <list> <BEFORE|AFTER> <value>)
set (defines DEF1 DEF2)
list (INSERT defines BEFORE "-D")
# result: -D DEF1 -D DEF2
-
REPLACE_AT
,REPLACE_ITEM
,REPLACE
: To replace elements with new value.
# list (REPLACE_AT <list> <index> [<index> ...] <new value>)
# list (REPLACE_ITEM <list> <value> [<value> ...] <new value>)
# list (REPLACE <list> <regex> <new value>)
set (defines DEF1 DEF2 OTHER)
list (REPLACE defines "(.+[0-1]+)$" "NEW_\\1")
# result: NEW_DEF1 NEW_DEF2 OTHER
-
TOUPPER
,TOUPPER_AT
,TOUPPER_ITEM
,TOLOWER
,TOLOWER_AT
,TOLOWER_ITEM
: change case of all list's elements.
# list (TOUPPER <list>)
# list (TOUPPER_AT <list> <index> [<index> ...])
# list (TOUPPER_ITEM <list> <value> [<value> ...])
# list (TOLOWER <list>)
# list (TOLOWER_AT <list> <index> [<index> ...])
# list (TOLOWER_ITEM <list> <value> [<value> ...])