pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: combining string values


From: Jason Stover
Subject: Re: combining string values
Date: Mon, 5 Jan 2009 12:10:57 -0500
User-agent: Mutt/1.5.18 (2008-05-17)

On Sun, Jan 04, 2009 at 01:10:16PM -0800, Ben Pfaff wrote:
> Jason Stover <address@hidden> writes:
> 
> > I need to combine multiple string values into a single
> > string, in a one-to-one way. For example, in the following
> > data set, there are two variables, each with two values:
> >
> >     var1            var2
> >     ae              f
> >     a               ef
> >
> > I don't want to just concatenate the values because
> > I would have aef in both cases.
> 
> If you strip the whitespace at the end of each string, this is
> true.  If you retain the whitespace, then you have "aef " and "a
> ef", which are of course different.

Then what about this:

     var1       var2
     a e        f
     a          e f

If whitespace is allowed in a value, then we would concatenate to get
"a e f " in both cases.

> 
> > I can work around this by using strtol, or something
> > like it. 
> 
> I don't see how strtol is relevant?

To avoid concatenating, I had been thinking of changing each string to
an integer, then using a one-to-one function from the ordered
n-tuples of integers to the integers.  For example, something like:

        value  ae --> 1
        value   f -->  2
        value  aeu --> 87

Then compute n := g (1,2,87), where g is some invertible function. I
had planned to use strtol to map strings to integers. Maybe that's not
the right way.

But to take a step back: What is a good way to create a new union
value from a list of other union values, that avoids collisions?
Concatenate with some character other than whitespace?

-Jason




reply via email to

[Prev in Thread] Current Thread [Next in Thread]