From: Dave Thomas Date: 2002-03-04T12:36:23+09:00 Subject: Re: string to array and back Ron Jeffries writes: > I'm working on the theoretical operation that would convert a plain string like > 'MIjeffries' into a "record" (I use the term informally) that would look like > > { 'MI'[state], 'jeffries'[name] } > > where the { } are set brackets, not hash brackets, and [foo] means that the > scope (field name?) is foo. > > This is wanting to take place in two steps, for theoretical and atomic operation > reasons, the first step being to convert to > > { 'MI'[0], 'jeffries'[1] } > > The scopes here are actual integers. The scopes above are strings. To do this > operation, I need to connect the original set with a "control" set that will > look like { {0,1}[0], { 2,3,4,5,6,7,8,9}[1] } > > So my deal is that in one and the same context, I've got some sets that look > like string information and some that look like collections of numbers, and they > need to inter-operate. I can probably either write my own iterator or wrap them > in something to get what I want. It kinda sounds like you're really dealing with symbols. Would #intern etc help at all? { :state => :MI, :name => :Jeffries } (where {} _are_ hash constructors). Then you could define your set operations across hash slices... (if I understand where you're going) Dave