in reply to Sneaky glob trick (was Web-Safe Color Chart)
in thread Web-Safe Color Chart
First of all, glob expands the pattern according to shell
conventions, so
glob "foob{a,b,c}r"returns the list
('foobar', 'foobbr', 'foobcr')just like bash would return 'foobar foobbr foobcr' expandig metacharacters
The x operator applied to a string repeats the string the specified number of times, so
"{a,b,c}" x 3 evaluates as "{a,b,c}{a,b,c}{a,b,c}"
When you feed this expression to glob, the result is a list of all the possible combinations of a, b and c in a string of three characters, from 'aaa' to 'ccc'.
This could be easily achieved through magical string autoincrement, but the beauty of this method (very nice, I love it!) is that it applies to any set of strings to combine, not just characters.
-- TMTOWTDI
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Web-Safe Color Chart
by blakem (Monsignor) on Oct 05, 2001 at 14:41 UTC | |
by trantor (Chaplain) on Oct 05, 2001 at 14:56 UTC |