compression of strings into curly braces
- From: "ben.ruttATgmail.com" <ben.rutt@xxxxxxxxx>
- Date: 12 May 2007 15:35:20 -0700
People when authoring technical papers often write things like:
email: {foo,bar}@domain.edu
If I'm in the bash shell on unix, I might write this snippet check a
bunch of hostnames for their system load, e.g.
for host in host{1,2,3}; do rsh $host uptime; done
so this brace usage is very expressive and convenient and easy to use
to expand a string into a set of related members. I'm currently
interested in going the other direction. e.g. given a list of strings
like
host1.domain.com
host2.domain.com
host3.domain.com
as input to a program, how is it possible to turn this into
host{1,2,3}.domain.com? it would seem that this really requires a
compression algorithm. ultimately with this transformation you are
run-length encoding, as plain text, contiguous stretches of multiple
elements which are similar, while the variances are grouped into sets
with curly braces (we can assume there are no { } or , characters in
the input, so they can be used to represent sets).
Has anyone seen this problem before? Does it have a name? In this
case, I am indeed looking to compress a list of hostnames into a short
but readable list, but would enjoy looking at a general solution. note
it gets trickier if you get this set as input:
host1.domain1.com
host2.domain1.com
host3.domain1.com
host1.mydomain2.com
host2.mydomain2.com
host3.mydomain2.com
in this case, the 2 obvious groups differ in multiple places so it
seems you need as output:
host{1,2,3}.domain1.com host{1,2,3}.mydomain2.com
but the set
host1.domain1.com
host2.domain1.com
host3.domain1.com
host1.domain2.com
host2.domain2.com
host3.domain2.com
can be turned into host{1,2,3}.domain{1,2}.com
thanks for any insight or recognition of this problem. or pointers to
libraries or algorithms which have solved this.
.
- Follow-Ups:
- Re: compression of strings into curly braces
- From: Puckdropper
- Re: compression of strings into curly braces
- Prev by Date: Re: Search Engine I've Been Working On
- Next by Date: Non-programmer looking for advice in learning SQL
- Previous by thread: Integer Linear Programming from C++ application
- Next by thread: Re: compression of strings into curly braces
- Index(es):
Relevant Pages
|
Loading