Java Collections List : Converting from List '<Column <String1, String2>>' to 'List <String1>'

  • Permalink
  • submit to reddit
  • Email
  • Follow



I have a function that returns a list like this:-

List <Column <String1, String2>>

Next I want to pass this list to a 2nd function, but 2nd function just need=
s a list which contains only 1st part (string1) of the Column(s) of the abo=
ve list.

So I want pass just this list to 2nd function:-

List <String1>

What would be the best way to do this ??

[my use case: Both the functions are from a library that I use to access da=
tabase(Cassandra) for a web application. 1st function gives me a list of al=
l columns which has two parts name(String1) and value(String2). So 1st func=
tion gives me a list of all columns(each of which has two strings) then I j=
ust need to use the list of column names to supply it to 2nd function that'=
ll query the DB for those columns.]
0
Reply asil 2/19/2011 12:04:53 PM

See related articles to this posting

On 2/19/11 8:04 PM, asil klin wrote:
>
>
> I have a function that returns a list like this:-
>
> List<Column<String1, String2>>
>
> Next I want to pass this list to a 2nd function, but 2nd function just needs a list which contains only 1st part (string1) of the Column(s) of the above list.
>
> So I want pass just this list to 2nd function:-
>
> List<String1>
>
> What would be the best way to do this ??

If the second method is already written and there is the literal 
requirement that you pass a List<String> to it (I've never heard of the 
"String1" type, so don't really know what that's supposed to mean, if 
not simply a "String"), then I think you are pretty much stuck copying 
the individual strings from your Column instance into the new 
List<String> list.

Note that with a little effort, you can implement a .NET-like 
"enumerable" solution, in which the new object need not actually copy 
the entire data set, but rather simply "project" from the original.

In C#, it's very concise:

   void method2(IEnumerable<string> names)
   {
     foreach (string name in names)
     {
       // do something
     }
   }

where you call like this:

   List<Column> columns = …; // initialized somehow

   method2(columns.Select(column => column.String1));


But you can accomplish much the same sort of thing, albeit with not 
quite as concise a call site (but at least the entire collection doesn't 
have to be duplicated). For example:


public interface Select<T, S>
{
     S select(T t);
}


public class Iterables
{
   public static <T, S> Iterable<S> Select(Iterable<T> source, Select<T, 
S> select)
   {
       return new SelectIterable<T, S>(source, select);
   }

   private static class SelectIterable<T, S> implements Iterable<S>
   {
       private final Iterable<T> source;
       private final Select<T, S> select;

       public SelectIterable(Iterable<T> source, Select<T, S> select)
       {
           this.source = source;
           this.select = select;
       }

       @Override
       public java.util.Iterator<S> iterator()
       {
           return new Iterator(source.iterator());
       }

       private class Iterator implements java.util.Iterator<S>
       {
         private final java.util.Iterator<T> source;

         public Iterator(java.util.Iterator<T> source)
         {
             this.source = source;
         }

         @Override
         public boolean hasNext()
         {
             return source.hasNext();
         }

         @Override
         public S next()
         {
             return SelectIterable.this.select.select(source.next());
         }

         @Override
         public void remove()
         {
             throw new UnsupportedOperationException();
         }
       }
   }
}


public class Column
{
     private final String string1;
     private final String string2;

     public Column(String string1, String string2)
     {
         this.string1 = string1;
         this.string2 = string2;
     }

     public String getString1() { return string1; }
     public String getString2() { return string2; }
}


import java.util.ArrayList;
import java.util.List;

public class Main
{

     /**
      * @param args
      */
     public static void main(String[] args)
     {
         List<Column> columns = new ArrayList<Column>();

         columns.add(new Column("1", "A"));
         columns.add(new Column("2", "B"));
         columns.add(new Column("3", "C"));

         method2(Iterables.Select(columns, new Select<Column, String>()
             {
                public String select(Column column)
                {
                    return column.getString1();
                }
             }));
     }

     private static void method2(Iterable<String> names)
     {
         for (String name : names)
         {
             System.out.println(name);
         }
     }

}
0
Reply Peter 2/19/2011 1:19:37 PM

On 02/19/2011 07:04 AM, asil klin wrote:
>
>
> I have a function that returns a list like this:-

DO NOT MULTI-POST!

-- 
Lew
Honi soit qui mal y pense.
0
Reply Lew 2/19/2011 3:08:38 PM

On 19/02/2011 14:19, Peter Duniho allegedly wrote:

> But you can accomplish much the same sort of thing, albeit with not
> quite as concise a call site (but at least the entire collection doesn't
> have to be duplicated). For example:
>
>
> public interface Select<T, S>
> {
> S select(T t);
> }
>
>
> public class Iterables
> {
> public static <T, S> Iterable<S> Select(Iterable<T> source, Select<T, S>
> select)
> {
> return new SelectIterable<T, S>(source, select);
> }
>
> private static class SelectIterable<T, S> implements Iterable<S>
> {
> private final Iterable<T> source;
> private final Select<T, S> select;
>
> public SelectIterable(Iterable<T> source, Select<T, S> select)
> {
> this.source = source;
> this.select = select;
> }
>
> @Override
> public java.util.Iterator<S> iterator()
> {
> return new Iterator(source.iterator());
> }
>
> private class Iterator implements java.util.Iterator<S>
> {
> private final java.util.Iterator<T> source;
>
> public Iterator(java.util.Iterator<T> source)
> {
> this.source = source;
> }
>
> @Override
> public boolean hasNext()
> {
> return source.hasNext();
> }
>
> @Override
> public S next()
> {
> return SelectIterable.this.select.select(source.next());
> }
>
> @Override
> public void remove()
> {
> throw new UnsupportedOperationException();
> }
> }
> }
> }
>
>
> public class Column
> {
> private final String string1;
> private final String string2;
>
> public Column(String string1, String string2)
> {
> this.string1 = string1;
> this.string2 = string2;
> }
>
> public String getString1() { return string1; }
> public String getString2() { return string2; }
> }
>
>
> import java.util.ArrayList;
> import java.util.List;
>
> public class Main
> {
>
> /**
> * @param args
> */
> public static void main(String[] args)
> {
> List<Column> columns = new ArrayList<Column>();
>
> columns.add(new Column("1", "A"));
> columns.add(new Column("2", "B"));
> columns.add(new Column("3", "C"));
>
> method2(Iterables.Select(columns, new Select<Column, String>()
> {
> public String select(Column column)
> {
> return column.getString1();
> }
> }));
> }
>
> private static void method2(Iterable<String> names)
> {
> for (String name : names)
> {
> System.out.println(name);
> }
> }
>
> }

This is what I'd suggest, too. Although I'd call it 'map' rather than
'select'. And I would recommend going the whole way and making it a
(read-only) collection (by extending AbstractCollection) or a
(read-only) List (by extending AbstractList), rather than using only
Iterable. Iterable is OK, but lacks useful features (notably, size())
for the more than basic uses. And since you're writing some code
already, might as well put in a little extra effort and get the whole bang.

I've written a little framework exactly like this some time ago. It is
insanely useful -- which shouldn't come as a surprise for anyone who's
ever heard of functional programming.

Note that the main advantage is that this approach is that it reflects
modifications of the underlying object transparently, and thus blends in
very nicely with an object-oriented structure.

-- 
DF.
0
Reply Daniele 2/19/2011 4:50:37 PM

On 2/20/11 12:50 AM, Daniele Futtorovic wrote:
> This is what I'd suggest, too. Although I'd call it 'map' rather than
> 'select'.

The word "select" simply came from my exposure to .NET. Actually, I find 
the word "project" (as a verb) to be more appropriate, though I agree 
"map" is fine too.

I don't think the precise name is going to matter too much.  :)

> And I would recommend going the whole way and making it a
> (read-only) collection (by extending AbstractCollection) or a
> (read-only) List (by extending AbstractList), rather than using only
> Iterable.

It will depend on how one intends to use it.  Again, because I am 
following the .NET model, Iterable is the first choice only due to that.

However, it's worth pointing out that Iterable allows for sequences 
larger than 2GB items, while extending AbstractList or 
AbstractCollection, because those classes use an int to describe their 
length (and in the case of AbstractList, to enumerate as well).

Also, using Iterable means that the code is usable for a broader range 
of inputs.  I.e. is more re-usable.  Extending AbstractList or 
AbstractCollection will limit the uses to wrapping lists or collections.

> Iterable is OK, but lacks useful features (notably, size())
> for the more than basic uses.

..NET addresses that lack by including the extension method Count() (in 
my code, that would show up as a static method in the Iterables class), 
which checks for common interfaces that support a direct retrieval of 
the collection length, and if those are not available, then enumerates 
the entire collection as a fall-back.

One could easily do the same here, providing the greater re-usability 
without sacrificing countability or efficiency.

> And since you're writing some code
> already, might as well put in a little extra effort and get the whole bang.

One might say that since you're writing some code already, you might as 
well put in a little extra effort and make the code as broadly re-usable 
as possible.  :)

> I've written a little framework exactly like this some time ago. It is
> insanely useful -- which shouldn't come as a surprise for anyone who's
> ever heard of functional programming.

Right.  The .NET features come from LINQ, which has a strong functional 
bent to it.  Of course, the other functional-like features in C# work 
closely with LINQ and the Enumerable extension methods in a way that is 
not possible with the current version of Java.  But one can get a large 
portion of the same benefit, with some worthwhile effort.

> Note that the main advantage is that this approach is that it reflects
> modifications of the underlying object transparently, and thus blends in
> very nicely with an object-oriented structure.

I'm not sure I'd call that the _main_ advantage.  In fact, it can be a 
bit of a pitfall in .NET, as chained enumerators are all re-run each 
time you enumerate the last link of the chain.

Not only is it a potential performance issue, variable capturing can 
result in some non-intuitive (and often unintended) results, because 
even the parameters of the enumerations may be changed after the fact, 
having effect on subsequent enumerations of the new enumerable object.

But it definitely can be a very handy aspect of the approach, if one is 
careful to mind the implications of the implementation.

Pete
0
Reply Peter 2/19/2011 5:23:48 PM

On 2/20/11 1:23 AM, Peter Duniho wrote:
> [...]
> However, it's worth pointing out that Iterable allows for sequences
> larger than 2GB items, while extending AbstractList or
> AbstractCollection, because those classes use an int to describe their
> length (and in the case of AbstractList, to enumerate as well).  [...]

Sorry…I really did mean to finish that thought.  Hopefully where I was 
going with it was obvious, but the conclusion is that extending the 
Abstract… types will necessarily limit sequences to 2GB items or fewer.

Some of the time that might matter, a lot of the time it probably won't. 
  But it's a consideration.

Also, it should go without saying that the code I posted is simply to 
illustrate the technique.  It's usable as-is, but if one is going to 
develop this kind of abstraction, they will likely wind up with a 
broader feature set, error-checking, etc.

Pete
0
Reply Peter 2/19/2011 5:38:53 PM

On 19/02/2011 18:23, Peter Duniho allegedly wrote:
> On 2/20/11 12:50 AM, Daniele Futtorovic wrote:
>> This is what I'd suggest, too. Although I'd call it 'map' rather
>> than 'select'.
>
> The word "select" simply came from my exposure to .NET. Actually, I
> find the word "project" (as a verb) to be more appropriate, though I
> agree "map" is fine too.
>
> I don't think the precise name is going to matter too much. :)

Sure.

>> And I would recommend going the whole way and making it a
>> (read-only) collection (by extending AbstractCollection) or a
>> (read-only) List (by extending AbstractList), rather than using
>> only Iterable.
>
> It will depend on how one intends to use it. Again, because I am
> following the .NET model, Iterable is the first choice only due to
> that.
>
> However, it's worth pointing out that Iterable allows for sequences
> larger than 2GB items, while extending AbstractList or
> AbstractCollection, because those classes use an int to describe
> their length (and in the case of AbstractList, to enumerate as
> well).

Good point; I hadn't thought of that. Still, as the underlying structure
is already one that is constrained by the 2^31 -1 limit (being, in the
OP's case, a java.util.List), and considering how the overwhelming
majority of use-cases would fall hither of that limit, I think it would
be safe to code for these uses. Might of course make the Iterable
available, too.


> Also, using Iterable means that the code is usable for a broader
> range of inputs. I.e. is more re-usable. Extending AbstractList or
> AbstractCollection will limit the uses to wrapping lists or
> collections.

Now I'm not sure you got what I meant. I meant that the content-mapping
code you showed for Iterable structures could be extended so that the
"view" objects would be Collections, when mapping the contents of any
class implementing Collection, or Lists, when mapping the contents of
any class implementing List; and that it's very easy to do by making the
"view" Object extend Abstract(Collection|List), because you only have a
very few methods to implement (provided you make them read-only -- if
they're writable it becomes slightly more tricky).

I agree that Iterable is an interface that serves broader purposes and
can be implemented by a wider range of objects than Collection et al.,
but nevertheless a great share of the code (my code, at least) consists
of working with Collections. It's fine if it's broad, but not if it
being broad lessens its usefulness.


>> Iterable is OK, but lacks useful features (notably, size()) for the
>> more than basic uses.
>
> ..NET addresses that lack by including the extension method Count()
> (in my code, that would show up as a static method in the Iterables
> class), which checks for common interfaces that support a direct
> retrieval of the collection length, and if those are not available,
> then enumerates the entire collection as a fall-back.

Is that the equivalent of this "defender methods" stuff I've been
hearing about?


>> Note that the main advantage is that this approach is that it
>> reflects modifications of the underlying object transparently, and
>> thus blends in very nicely with an object-oriented structure.
>
> I'm not sure I'd call that the _main_ advantage. In fact, it can be a
>  bit of a pitfall in .NET, as chained enumerators are all re-run each
>  time you enumerate the last link of the chain.
>
> Not only is it a potential performance issue, variable capturing can
>  result in some non-intuitive (and often unintended) results, because
>  even the parameters of the enumerations may be changed after the
> fact, having effect on subsequent enumerations of the new enumerable
> object.
>
> But it definitely can be a very handy aspect of the approach, if one
> is careful to mind the implications of the implementation.

Sorry but you totally lost me there.

I wouldn't claim for a second that these things are going to be very
efficient. To me, the main use is as a specific "view" of a given
structure, short-term objects which I'm going briefly to manipulate and
then discard. In those cases, there is next to no performance impact,
because what the view is doing, I would have to do if I didn't have it
-- it just hides it and provides a handy syntax, making the application
logic clearer.

-- 
DF.
0
Reply Daniele 2/20/2011 12:05:06 AM

On 2/20/11 8:05 AM, Daniele Futtorovic wrote:
> Good point; I hadn't thought of that. Still, as the underlying structure
> is already one that is constrained by the 2^31 -1 limit (being, in the
> OP's case, a java.util.List) [...]

If the "underlying structure" is simply an Iterable, there is no such 
limit.  If you got the Iterable from a List, then yes…it's got that 
limit.  But not all Iterables come from Lists.

>> Also, using Iterable means that the code is usable for a broader
>> range of inputs. I.e. is more re-usable. Extending AbstractList or
>> AbstractCollection will limit the uses to wrapping lists or
>> collections.
>
> Now I'm not sure you got what I meant. I meant that the content-mapping
> code you showed for Iterable structures could be extended so that the
> "view" objects would be Collections, when mapping the contents of any
> class implementing Collection, or Lists, when mapping the contents of
> any class implementing List; and that it's very easy to do by making the
> "view" Object extend Abstract(Collection|List), because you only have a
> very few methods to implement (provided you make them read-only -- if
> they're writable it becomes slightly more tricky).

I don't know if I understand what you mean either.  I wouldn't want to 
have to write the code three different times, implementing Iterable, 
List, _and_ Collection.  But that sounds like what you're proposing.

In a full-blown implementation, you can provide List- and 
Collection-like features in the Iterables class in the same way I 
pointed out a size() method can be implemented: check for List or 
Collection and use that implementation if present, otherwise iterate 
through the Iterable to achieve it "the hard way".

> I agree that Iterable is an interface that serves broader purposes and
> can be implemented by a wider range of objects than Collection et al.,
> but nevertheless a great share of the code (my code, at least) consists
> of working with Collections. It's fine if it's broad, but not if it
> being broad lessens its usefulness.

There's no reason it should.

>>> Iterable is OK, but lacks useful features (notably, size()) for the
>>> more than basic uses.
>>
>> ..NET addresses that lack by including the extension method Count()
>> (in my code, that would show up as a static method in the Iterables
>> class), which checks for common interfaces that support a direct
>> retrieval of the collection length, and if those are not available,
>> then enumerates the entire collection as a fall-back.
>
> Is that the equivalent of this "defender methods" stuff I've been
> hearing about?

I have no idea.  What "defender methods" have you been hearing about? 
I've never even heard the term.

>>> Note that the main advantage is that this approach is that it
>>> reflects modifications of the underlying object transparently, and
>>> thus blends in very nicely with an object-oriented structure.
>>
>> I'm not sure I'd call that the _main_ advantage. In fact, it can be a
>> bit of a pitfall in .NET, as chained enumerators are all re-run each
>> time you enumerate the last link of the chain.
>>
>> Not only is it a potential performance issue, variable capturing can
>> result in some non-intuitive (and often unintended) results, because
>> even the parameters of the enumerations may be changed after the
>> fact, having effect on subsequent enumerations of the new enumerable
>> object.
>>
>> But it definitely can be a very handy aspect of the approach, if one
>> is careful to mind the implications of the implementation.
>
> Sorry but you totally lost me there.
>
> I wouldn't claim for a second that these things are going to be very
> efficient. [...]

My point is not that the performance issue is a problem per se.  Simply 
that it exists, and that for the same reason it exists there can 
potentially be other non-intuitive behaviors.  I.e. it's not always 
_beneficial_ that modifications to the original data structure are also 
reflection in the new Iterable object.

I'm simply saying that while in some cases having modifications to the 
original data structure be visible in the new Iterable object as well, 
this isn't always a desirable behavior, never mind the most important 
aspect.

But honestly, what the "main advantage" is, isn't all that important a 
question.  Different people in different situations will find different 
uses for something like this.  I only commented by way of offering an 
alternate perspective, not for the purpose of trying to dissuade you 
from yours.  :)

Pete
0
Reply Peter 2/20/2011 1:00:36 AM

On 19-02-2011 20:00, Peter Duniho wrote:
> On 2/20/11 8:05 AM, Daniele Futtorovic wrote:
>> Is that the equivalent of this "defender methods" stuff I've been
>> hearing about?
>
> I have no idea. What "defender methods" have you been hearing about?
> I've never even heard the term.

http://cr.openjdk.java.net/~darcy/DefenderMethods.pdf

Arne
0
Reply UTF 2/20/2011 1:05:02 AM

On 2/20/11 9:05 AM, Arne Vajhøj wrote:
> On 19-02-2011 20:00, Peter Duniho wrote:
>> On 2/20/11 8:05 AM, Daniele Futtorovic wrote:
>>> Is that the equivalent of this "defender methods" stuff I've been
>>> hearing about?
>>
>> I have no idea. What "defender methods" have you been hearing about?
>> I've never even heard the term.
>
> http://cr.openjdk.java.net/~darcy/DefenderMethods.pdf

Huh?  Don't you mean http://www.lmgtfy.com/?q=java+defender+methods

:)

Anyway, no Daniele…I hadn't heard about that.  That feature is similar 
to what I meant, but it involves run-time support, whereas I simply 
meant that the "extension method" itself could do the necessary run-time 
check to accomplish the same thing.

I see the appeal for the "defender method" approach, but it's not quite 
what I was talking about.  My discussion isn't assuming any new Java 
features, simply providing static methods to execute with existing Java 
interfaces (and Iterable in particular).  Those static methods could 
explicitly check for, casting to and calling if available, the 
(presumably) more efficient implementations for such methods, but would 
always have a fallback implementation guaranteed to work with the 
original Iterable interface.

As far as "defender methods" go, IMHO if one is going to make such a 
change to Java, there are two important aspects that need to be 
included:  one needs to be able to specify more than one default 
interface method to serve as the default implementation, and one needs 
to be able to specify a static method to fall back on should there be 
none of the interface implementations available.

That said, I'm a bit skeptical of that approach anyway, because it seems 
to encourage the modification of existing interfaces.  Applied here, it 
would theoretically lead to the addition of size() and get(int) methods 
to the Iterable interface which, to me, would detract from the 
simplicity and directness of that interface.

The motivation seems to be that "it's difficult to change an interface 
once published".  But for me, that's one of the benefits of interfaces. 
  Yes, version control on an interface is hard.  It's _supposed_ to be!  :)

Even as I might find myself at times desirable to call those methods on 
an Iterable object, I feel like I should do so only judiciously and 
while understanding that doing so could be a costly operation.  Adding 
them to the interface itself would, I think, encourage inappropriate 
generalization of code related to the Iterable interface.

It seems to me that if the code really needs such regular use of size() 
and/or get() that it's inconvenient to call a static method, one ought 
to consider simply using List or Collection as the input interface in 
the first place.

(And I write that even as I'm a big fan of C#'s extension methods, which 
do provide a _syntactic_ — not run-time — shortcut for calling such 
static methods).

Pete
0
Reply Peter 2/20/2011 1:39:16 AM

On 11-02-19 09:05 PM, Arne Vajhøj wrote:
> On 19-02-2011 20:00, Peter Duniho wrote:
>> On 2/20/11 8:05 AM, Daniele Futtorovic wrote:
>>> Is that the equivalent of this "defender methods" stuff I've been
>>> hearing about?
>>
>> I have no idea. What "defender methods" have you been hearing about?
>> I've never even heard the term.
>
> http://cr.openjdk.java.net/~darcy/DefenderMethods.pdf
>
> Arne

I respect Goetz, but it's a lousy name. IMO.

AHS

-- 
We must recognize the chief characteristic of the modern era - a 
permanent state of what I call violent peace.
-- James D. Watkins
0
Reply Arved 2/20/2011 1:40:30 AM

On 19-02-2011 20:40, Arved Sandstrom wrote:
> On 11-02-19 09:05 PM, Arne Vajhøj wrote:
>> On 19-02-2011 20:00, Peter Duniho wrote:
>>> On 2/20/11 8:05 AM, Daniele Futtorovic wrote:
>>>> Is that the equivalent of this "defender methods" stuff I've been
>>>> hearing about?
>>>
>>> I have no idea. What "defender methods" have you been hearing about?
>>> I've never even heard the term.
>>
>> http://cr.openjdk.java.net/~darcy/DefenderMethods.pdf
>
> I respect Goetz, but it's a lousy name. IMO.

He explains the name in the text.

I don't have a problem with it.

But I think that the headline should be "virtual extension methods"
because that is what it is all about. The "defender methods" is
just a part of it.

Arne

0
Reply UTF 2/20/2011 1:49:41 AM

On 11-02-19 09:49 PM, Arne Vajhøj wrote:
> On 19-02-2011 20:40, Arved Sandstrom wrote:
>> On 11-02-19 09:05 PM, Arne Vajhøj wrote:
>>> On 19-02-2011 20:00, Peter Duniho wrote:
>>>> On 2/20/11 8:05 AM, Daniele Futtorovic wrote:
>>>>> Is that the equivalent of this "defender methods" stuff I've been
>>>>> hearing about?
>>>>
>>>> I have no idea. What "defender methods" have you been hearing about?
>>>> I've never even heard the term.
>>>
>>> http://cr.openjdk.java.net/~darcy/DefenderMethods.pdf
>>
>> I respect Goetz, but it's a lousy name. IMO.
>
> He explains the name in the text.
>
> I don't have a problem with it.
>
> But I think that the headline should be "virtual extension methods"
> because that is what it is all about. The "defender methods" is
> just a part of it.
>
> Arne
>
I know he explained it; I read the paper. :-) But it was an unnecessary 
and cutesy name. What's wrong with virtual extension method? If Goetz' 
pet name takes off then it'll be just more useless jargon to confuse 
novices...and without having read the specific explanation for it, the 
name isn't even meaningful.

Like I said, I respect the guy a great deal. But I'll take him up on his 
implied out, when he says "you could call these “public defender” 
methods...". I could, but I won't. :-)

AHS

-- 
We must recognize the chief characteristic of the modern era - a 
permanent state of what I call violent peace.
-- James D. Watkins
0
Reply Arved 2/20/2011 5:33:17 AM

On Sat, 19 Feb 2011 04:04:53 -0800 (PST), asil klin
<asdkl93@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>What would be the best way to do this ??

you pretty well have to create a new list and copy the items over one
at a time.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Refactor early. If you procrastinate, you will have
even more code to adjust based on the faulty design.
..

0
Reply Roedy 2/20/2011 7:50:01 AM

In article <8f13c843-eced-41f8-b20b-901979548436
@glegroupsg2000goo.googlegroups.com>, asdkl93@gmail.com says...
> 
> I have a function that returns a list like this:-
> 
> List <Column <String1, String2>>
> 
> Next I want to pass this list to a 2nd function, but 2nd function just needs a list which contains only 1st part (string1) of the Column(s) of the above list.
> 
> So I want pass just this list to 2nd function:-
> 
> List <String1>
> 
> What would be the best way to do this ??

> [my use case: Both the functions are from a library that I use to 
> access database(Cassandra) for a web application. 1st function gives 
> me a list of all columns which has two parts name(String1) and value
> (String2). So 1st function gives me a list of all columns(each of 
> which has two strings) then I just need to use the list of column 
> names to supply it to 2nd function that'll query the DB for those 
> columns.]

Naive Solution:

List<String> names= new ArrayList<String>();
for(Column<String1,String2> c : columns){
 names.add(c.getName()); //or any appropriate method to get access
}

Seriously: if that's yous solution I don't understand your question, 
because it's an no-brainer that even a novice programmer should be able 
to find out all by himself in less than 10 minutes.

Anyway, if that's your solution, there is still another way to do it 
nicely, which is not that apparrent and it goes by help of the "Apache 
commons" library:
http://commons.apache.org/collections/
http://commons.apache.org/collections/api-release/index.html

Here is how it looks like:

Transformer columnToName = new Transformer(){
 public void transform(Object o){
  return ((Column)o).getName(); //or any appropriate method
 }
};
List<String> names= new ArrayList<String>();
CollectionUtils.collect(columns, columnToName, names);

This style makes it possible to share and reuse the Transformer-
Implementation instead of copying the extracting code everywhere. That 
might be pretty helpful if the structure of your data changes and forces 
you to find and change every bit of the program that relies on the old 
one. Especially if the transformation-process is less trivial and there 
are pitfalls to avoid, sharing and passing around a good reference 
implementation may come handy. Another fine thing is that the name of 
the transformer variable can serve as documentation of what is happening 
here.

Kind regards
Wanja

-- 
...Alesi's problem was that the back of the car was jumping up and down 
dangerously - and I can assure you from having been teammate to 
Jean Alesi and knowing what kind of cars that he can pull up with, 
when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer]

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
0
Reply Wanja 2/20/2011 11:04:21 AM

On 02/20/2011 06:04 AM, Wanja Gayk wrote:
> In article<8f13c843-eced-41f8-b20b-901979548436
> @glegroupsg2000goo.googlegroups.com>, asdkl93@gmail.com says...
>>
>> I have a function that returns a list like this:-
>>
>> List<Column<String1, String2>>
>>
>> Next I want to pass this list to a 2nd function, but 2nd function just needs a list which contains only 1st part (string1) of the Column(s) of the above list.
>>
>> So I want pass just this list to 2nd function:-
>>
>> List<String1>
>>
>> What would be the best way to do this ??
>
>> [my use case: Both the functions are from a library that I use to
>> access database(Cassandra) for a web application. 1st function gives
>> me a list of all columns which has two parts name(String1) and value
>> (String2). So 1st function gives me a list of all columns(each of
>> which has two strings) then I just need to use the list of column
>> names to supply it to 2nd function that'll query the DB for those
>> columns.]
>
> Naive Solution:
>
> List<String>  names= new ArrayList<String>();

This does not fulfill the OP's condition that the list's base type be 'String1'.

A singularly poorly-named type, to be sure, but the one they asked for.

-- 
Lew
Honi soit qui mal y pense.
0
Reply Lew 2/20/2011 2:57:19 PM

On 20/02/2011 02:00, Peter Duniho allegedly wrote:
> On 2/20/11 8:05 AM, Daniele Futtorovic wrote:
>>> Also, using Iterable means that the code is usable for a broader
>>> range of inputs. I.e. is more re-usable. Extending AbstractList or
>>> AbstractCollection will limit the uses to wrapping lists or
>>> collections.
>>
>> Now I'm not sure you got what I meant. I meant that the content-mapping
>> code you showed for Iterable structures could be extended so that the
>> "view" objects would be Collections, when mapping the contents of any
>> class implementing Collection, or Lists, when mapping the contents of
>> any class implementing List; and that it's very easy to do by making the
>> "view" Object extend Abstract(Collection|List), because you only have a
>> very few methods to implement (provided you make them read-only -- if
>> they're writable it becomes slightly more tricky).
>
> I don't know if I understand what you mean either. I wouldn't want to
> have to write the code three different times, implementing Iterable,
> List, _and_ Collection. But that sounds like what you're proposing.

Yes, of course.

So, given:

     interface Mapper<In, Out> {
         Out map( In in );
     }

You'd have (possibly statically somewhere):

     <In, Out> Iterable<Out> createProjection( final Iterable<? extends 
In> iterable, final Mapper<? super In, ? extends Out> mapper );


     <In, Out> Collection<Out> createProjection( Collection<? extends 
In> coll, Mapper<? super In, ? extends Out> mapper );

     <In, Out> List<Out> createProjection( List<? extends In> list, 
Mapper<? super In, ? extends Out> mapper );

And for the less faint-hearted:

     <K, In, Out> Map<K, Out> createProjection( Map<K, ? extends In> 
map, Mapper<? super In, ? extends Out> mapper );

And for the truly brave:

     <K, In, Out> SortedMap<K, Out> createProjection( SortedMap<K, ? 
extends In> map, Mapper<? super In, ? extends Out> mapper );

If that's too much code to write for you, considering it's a toolset and 
the power it brings, then might as well stay in bed, if I may say so.


> In a full-blown implementation, you can provide List- and
> Collection-like features in the Iterables class in the same way I
> pointed out a size() method can be implemented: check for List or
> Collection and use that implementation if present, otherwise iterate
> through the Iterable to achieve it "the hard way".

Disagreed. The projection should be isomorphic. If you need size and 
only have an Iterable to work with, then something's wrong with your 
data structures in the first place.

<snip />'d the rest due to agreement.

-- 
DF.
0
Reply Daniele 2/21/2011 6:33:56 PM

In article <ijra47$2an$1@news.albasani.net>, noone@lewscanon.com says...

> > Naive Solution:
> >
> > List<String>  names= new ArrayList<String>();
> 
> This does not fulfill the OP's condition that the list's base type be 'String1'.

Nitpicking.
I understood rather that the OP was asking for an algorithm to extract 
one of both values. Changing the types to the own requirements is even 
more trivial.

Kind regards,


-- 
...Alesi's problem was that the back of the car was jumping up and down 
dangerously - and I can assure you from having been teammate to 
Jean Alesi and knowing what kind of cars that he can pull up with, 
when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer]

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
0
Reply Wanja 2/24/2011 11:51:27 PM

On 02/24/2011 06:51 PM, Wanja Gayk wrote:
> In article<ijra47$2an$1@news.albasani.net>, noone@lewscanon.com says...
>
>>> Naive Solution:
>>>
>>> List<String>   names= new ArrayList<String>();
>>
>> This does not fulfill the OP's condition that the list's base type be 'String1'.
>
> Nitpicking.
> I understood rather that the OP was asking for an algorithm to extract
> one of both values. Changing the types to the own requirements is even
> more trivial.

So you think attention to detail doesn't matter.

You are wrong.

"Nitpicking", as you attempt to disparage it, is vital to good programming.  I 
guess you're not a good programmer.

Learn to nitpick.  The difference between 'String1' and 'String' is likely to 
be significant in the real world.  Your casual attitude will create bugs.

-- 
Lew
Honi soit qui mal y pense.
0
Reply Lew 2/25/2011 12:05:44 AM

2011-02-25 01:05, Lew wrote:
> On 02/24/2011 06:51 PM, Wanja Gayk wrote:
>> In article<ijra47$2an$1@news.albasani.net>, noone@lewscanon.com says...
>>
>>>> Naive Solution:
>>>>
>>>> List<String>   names= new ArrayList<String>();
>>>
>>> This does not fulfill the OP's condition that the list's base type be
>>> 'String1'.
>>
>> Nitpicking.
>> I understood rather that the OP was asking for an algorithm to extract
>> one of both values. Changing the types to the own requirements is even
>> more trivial.
> 
> So you think attention to detail doesn't matter.
> 
> You are wrong.
> 
> "Nitpicking", as you attempt to disparage it, is vital to good
> programming.  I guess you're not a good programmer.
> 
> Learn to nitpick.  The difference between 'String1' and 'String' is
> likely to be significant in the real world.  Your casual attitude will
> create bugs.

Come on!
It's obvious that the OP did not intend that String1 and String2 should
be anything other than String. He used 1 and 2 to indicate which of the
String's should be placed in the derived List.


0
Reply Lars 2/25/2011 12:25:49 AM

In article <ik6rok$bdl$1@news.albasani.net>, noone@lewscanon.com says...

> > Nitpicking.
> > I understood rather that the OP was asking for an algorithm to extract
> > one of both values. Changing the types to the own requirements is even
> > more trivial.
> 
> So you think attention to detail doesn't matter.
> 
> You are wrong.
> 
> "Nitpicking", as you attempt to disparage it, is vital to good programming.  I 
> guess you're not a good programmer.

Following your argumentation the GOF book is written by a bunch of lousy 
programmers, as they only provide patterns instead of ansewering your 
particular question. Instead of providing you a ActionListener-Example, 
they just talk about observers- and command-patterns. How can they dare?

Guess what you want, my employer is happy, because I pay a lot of 
attention to detail. But this is not work and I'm not here to do other 
people's homework or prodive complete solutions. Still I will happily 
help to solve a problem by pointing someone into a possibly right 
direction, providing a guideline, or a pattern so to speak.

Kind ergards,



-- 
...Alesi's problem was that the back of the car was jumping up and down 
dangerously - and I can assure you from having been teammate to 
Jean Alesi and knowing what kind of cars that he can pull up with, 
when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer]

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
0
Reply Wanja 2/25/2011 12:37:13 AM

On 02/24/2011 07:25 PM, Lars Enderin wrote:
> 2011-02-25 01:05, Lew wrote:
>> On 02/24/2011 06:51 PM, Wanja Gayk wrote:
>>> In article<ijra47$2an$1@news.albasani.net>, noone@lewscanon.com says...
>>>
>>>>> Naive Solution:
>>>>>
>>>>> List<String>    names= new ArrayList<String>();
>>>>
>>>> This does not fulfill the OP's condition that the list's base type be
>>>> 'String1'.
>>>
>>> Nitpicking.
>>> I understood rather that the OP was asking for an algorithm to extract
>>> one of both values. Changing the types to the own requirements is even
>>> more trivial.
>>
>> So you think attention to detail doesn't matter.
>>
>> You are wrong.
>>
>> "Nitpicking", as you attempt to disparage it, is vital to good
>> programming.  I guess you're not a good programmer.
>>
>> Learn to nitpick.  The difference between 'String1' and 'String' is
>> likely to be significant in the real world.  Your casual attitude will
>> create bugs.
>
> Come on!
> It's obvious that the OP did not intend that String1 and String2 should

You call it "obvious".  In my work I have been corrected many, many times for 
assuming what I thought was "obvious", only to find out the specification was 
intended as stated.
> be anything other than String. He used 1 and 2 to indicate which of the
> String's should be placed in the derived List.

You base that on zero evidence, only your own assumptions.  I, on the other 
hand, assume the OP meant precisely what he wrote.  But you go right ahead and 
invent interpretations for him that are not what he said, sport.

-- 
Lew
Honi soit qui mal y pense.
0
Reply Lew 2/25/2011 9:55:59 PM

On 02/26/2011 09:51 AM, Wanja Gayk wrote:
> In article<ik98h3$fkc$2@news.albasani.net>, noone@lewscanon.com says...
>
>> You base that on zero evidence, only your own assumptions.
>> I, on the other  hand, assume the OP meant precisely what he wrote.
>
> ..on zero evidence.

Huh?  He wrote it.  That's not "zero" evidence.  It's the evidence of the 
actual post.  Go back and read it.  You will see:
> So I want pass just this list to 2nd function:-
>
> List <String1>

There's your evidence, right there.  Right in black and white.  Concretely. 
Posted and archived.  Look.  Right there.  It says, "String1".  See?

Think I'm misquoting him?  You can check for yourself.

-- 
Lew
Honi soit qui mal y pense.
0
Reply noone7 (4050) 3/3/2011 1:04:26 PM

Lew <noone@lewscanon.com> wrote:
> On 02/26/2011 09:51 AM, Wanja Gayk wrote:
>> In article<ik98h3$fkc$2@news.albasani.net>, noone@lewscanon.com says...
>>> You base that on zero evidence, only your own assumptions.
>>> I, on the other  hand, assume the OP meant precisely what he wrote.
>> ..on zero evidence.
> Huh?  He wrote it.  That's not "zero" evidence.

That ${someone} wrote ${something} is not "evidence" for
that ${someone} actually meant ${something}.

It's generally a strong indication, so your assumption wasn't
generally weak, but still it's no evidence.

Otoh, the stranger ${something} is (e.g. using String1 without
 further explanation of it), the weaker is even the indication.

0
Reply avl1 (2748) 3/3/2011 1:29:26 PM

On Mar 3, 8:29=A0am, Andreas Leitgeb <a...@gamma.logic.tuwien.ac.at>
wrote:
> Lew <no...@lewscanon.com> wrote:
> > On 02/26/2011 09:51 AM, Wanja Gayk wrote:
> >> In article<ik98h3$fk...@news.albasani.net>, no...@lewscanon.com says..=
..
> >>> You base that on zero evidence, only your own assumptions.
> >>> I, on the other =A0hand, assume the OP meant precisely what he wrote.
> >> ..on zero evidence.
> > Huh? =A0He wrote it. =A0That's not "zero" evidence.
>
> That ${someone} wrote ${something} is not "evidence" for
> that ${someone} actually meant ${something}.
>

Of course it is.

What other evidence do you have forwhat they mean?

> It's generally a strong indication, so your assumption wasn't
> generally weak, but still it's no evidence.
>

"Indication" is a synonym for "evidence", so you just disproved your
own thesis.

> Otoh, the stranger ${something} is (e.g. using String1 without
> =A0further explanation of it), the weaker is even the indication.

It's the only evidence you have.

How can you say that what someone says is not evidence of what they
mean?  That's crazy talk!

If you're not going to be intellectually honest, I'm not going to
play.

--
Lew
0
Reply lew (2468) 3/3/2011 5:00:33 PM

2011-03-03 18:00, Lew skrev:
> On Mar 3, 8:29 am, Andreas Leitgeb <a...@gamma.logic.tuwien.ac.at>
> wrote:
>> Lew <no...@lewscanon.com> wrote:
>>> On 02/26/2011 09:51 AM, Wanja Gayk wrote:
>>>> In article<ik98h3$fk...@news.albasani.net>, no...@lewscanon.com says....
>>>>> You base that on zero evidence, only your own assumptions.
>>>>> I, on the other  hand, assume the OP meant precisely what he wrote.
>>>> ..on zero evidence.
>>> Huh?  He wrote it.  That's not "zero" evidence.
>>
>> That ${someone} wrote ${something} is not "evidence" for
>> that ${someone} actually meant ${something}.
>>
> 
> Of course it is.
> 
> What other evidence do you have forwhat they mean?
> 
>> It's generally a strong indication, so your assumption wasn't
>> generally weak, but still it's no evidence.
>>
> 
> "Indication" is a synonym for "evidence", so you just disproved your
> own thesis.
> 
>> Otoh, the stranger ${something} is (e.g. using String1 without
>>  further explanation of it), the weaker is even the indication.
> 
> It's the only evidence you have.
> 
> How can you say that what someone says is not evidence of what they
> mean?  That's crazy talk!
> 
> If you're not going to be intellectually honest, I'm not going to
> play.

You are being ridiculous. The OP has not returned to the thread (scared
off by you?) we have no way to tell exactly what he meant with:

"I have a function that returns a list like this:-

List <Column <String1, String2>>

Next I want to pass this list to a 2nd function, but 2nd function just
needs a list which contains only 1st part (string1) of the Column(s) of
the above list.

So I want pass just this list to 2nd function:-

List <String1>

What would be the best way to do this ??

[my use case: Both the functions are from a library that I use to access
database(Cassandra) for a web application. 1st function gives me a list
of all columns which has two parts name(String1) and value(String2). So
1st function gives me a list of all columns(each of which has two
strings) then I just need to use the list of column names to supply it
to 2nd function that'll query the DB for those columns.]"


There is no evidence that his problem definition was meant to be
rigorous. The most likely interpretation is that String1 and String2
stand for the first and second String. Note the reference to "string1".
His problem formulation may be deficient, but you are being anal.

It's much less likely that he actually refers to two new types, String1
and String2.
0
Reply lars.enderin1 (162) 3/3/2011 5:54:17 PM

Lars Enderin wrote:
> It's much less likely that he actually refers to two new types, String1
> and String2.
>

That's a different statement from, "There's no evidence that he
actually refers to two new types."

You can make (in this case unfounded) assertions about likelikhood and
I won't question that.  But to claim there's "no evidence" when we
have the actual verbiage from the OP is stupid.  Of course there's
evidence.  Maybe not conclusive, but it's evidence.

You are the one being ridiculous making statements countervailing
claims I have not made.  I said I chose to believe what the OP said,
instead of inventing a different meaning, and you all dumped a load of
manure on me claiming there's "no evidence" that the OP meant what he
said.  Well, the statement is evidence in and of itself.  You call
that "ridiculous".  But it's true nonetheless.

What is ridiculous is to insist that the OP meant something
*different* from what he said with no evidence.  The burden of proof
is on the assertion that the meaning is different.  It's exactly the
kind of stupid assumption you all are making, "They *must* have meant
something different from the spec", that gets programmers in trouble.

I've been called to account by customers for this kind of mistake.
It's not theoretical.

--
Lew


0
Reply lew (2468) 3/3/2011 7:13:33 PM

Lew <lew@lewscanon.com> wrote:
> On Mar 3, 8:29 am, Andreas Leitgeb <a...@gamma.logic.tuwien.ac.at>
> wrote:
>> Lew <no...@lewscanon.com> wrote:
>> > On 02/26/2011 09:51 AM, Wanja Gayk wrote:
>> >> In article<ik98h3$fk...@news.albasani.net>, no...@lewscanon.com says...
>> >>> You base that on zero evidence, only your own assumptions.
>> >>> I, on the other  hand, assume the OP meant precisely what he wrote.
>> >> ..on zero evidence.
>> > Huh?  He wrote it.  That's not "zero" evidence.
>> That ${someone} wrote ${something} is not "evidence" for
>> that ${someone} actually meant ${something}.
> Of course it is.
> What other evidence do you have forwhat[sic] they mean?

Your definition of "evidence" seem to be incompatible.

Wikipedia says:
 "Evidence in its broadest sense includes everything that is
  used to determine or demonstrate the truth of an assertion.
  [...]
  Evidence is the currency by which one fulfills the burden
  of proof."

That doesn't sound like synonym to indication, to me.

Oh, and by your own logic&terms, we have now strong "evidence",
that you *meant* to create the new word "forwhat"...

0
Reply avl1 (2748) 3/3/2011 10:31:43 PM

On 03/03/11 13:29, Andreas Leitgeb wrote:
> Lew <noone@lewscanon.com> wrote:
>> On 02/26/2011 09:51 AM, Wanja Gayk wrote:
>>> In article<ik98h3$fkc$2@news.albasani.net>, noone@lewscanon.com says...
>>>> You base that on zero evidence, only your own assumptions.
>>>> I, on the other  hand, assume the OP meant precisely what he wrote.
>>> ..on zero evidence.
>> Huh?  He wrote it.  That's not "zero" evidence.
> 
> That ${someone} wrote ${something} is not "evidence" for
> that ${someone} actually meant ${something}.

It's better evidence that they meant it than that they didn't mean it.
Which is the essence of this [pointless] argument.

> 
> It's generally a strong indication, so your assumption wasn't
> generally weak, but still it's no evidence.

It's evidence, it is reasonably convincing evidence. It is not, however,
conclusive evidence. But in the absence of any conclusive evidence one
can only work with the evidence which is available, and that would lead
to the conclusion that the OP actually meant what they wrote.

> 
> Otoh, the stranger ${something} is (e.g. using String1 without
>  further explanation of it), the weaker is even the indication.
> 

Maybe so, but it's still a better assumption that they meant what they
wrote than that they didn't. In the absence of any evidence to the
contrary on what basis do you assume that they /did not/ mean it?

0
Reply nmw-news (85) 3/4/2011 9:12:04 AM

On 04/03/11 11:18, Andreas Leitgeb wrote:
> Nigel Wade <nmw-news@ion.le.ac.uk> wrote:
>> On 03/03/11 13:29, Andreas Leitgeb wrote:
>>> Lew <noone@lewscanon.com> wrote:
>>>> On 02/26/2011 09:51 AM, Wanja Gayk wrote:
>>>>> In article<ik98h3$fkc$2@news.albasani.net>, noone@lewscanon.com says...
>>>>>> You base that on zero evidence, only your own assumptions.
>>>>>> I, on the other  hand, assume the OP meant precisely what he wrote.
>>>>> ..on zero evidence.
>>>> Huh?  He wrote it.  That's not "zero" evidence.
>>> That ${someone} wrote ${something} is not "evidence" for
>>> that ${someone} actually meant ${something}.
>> It's better evidence that they meant it than that they didn't mean it.
> 
> Seems like you share Lew's relaxed definition of "evidence".

I think I share his actual definition of evidence, rather than the one
you've invented.

> 
>> Which is the essence of this [pointless] argument.
> 
> Pointless, not so much,  but not very fruitful, either. :-(
> 
>> But in the absence of any conclusive evidence one can only
>> work with the evidence which is available, and that would lead
>> to the conclusion that the OP actually meant what they wrote.
> 
> If using your relaxed definition of "evidence", 

my definition is accurate. You seem to be very confused between evidence
and inference.

this is correct,
> but doesn't apply. There *is* "evidence"(again, the relaxed one)
> that the numbers appended to String were meant to "tag" them for 
> later reference. 

no, not evidence, inference. You have no evidence whatsoever that the OP
did not mean what they stated, only your own inference.

So, the blatant fact that the OP actually stated something is somehow
not evidence (unless you "relax" the term in your words), but your
inference that the OP somehow didn't mean what they said is actual
evidence? And you accuse me and Lew of distorting facts?

Lew is either blind to these other sources of
> "evidence" or consciously ignores them. You, too?

No, we are blind to your ignoring actual evidence and instead
substituting your inferences in lieu, and then claiming it as evidence.

> 
> Thus, the precondition of "absence" of other "evidence" isn't an
> absolute given.
> 
> Just as much, as there exists an indication (inferred from his posting
> history, as well as the small Hamming-distance to the more sense making
> "for what") that Lew didn't mean to make up the word "forwhat".  Lew
> might, of course, anytime clarify if indeed he meant to make up a new
> word "forwhat".
> 

and the inference from your post, where you stipulate that just because
someone wrote something is not evidence that they meant it, is that  we
should accept nothing you write in your posts because it's probably not
what you actually meant. On that basis I'll take that lack of evidence
that you actually mean what you've written, and instead infer that you
are actually in full agreement with both Lew and myself.

-- 
Nigel Wade
0
Reply nmw-news (85) 3/4/2011 12:10:04 PM

Nigel Wade <nmw-news@ion.le.ac.uk> wrote:
>> Seems like you share Lew's relaxed definition of "evidence".
> I think I share his actual definition of evidence, rather than the one
> you've invented.

I'm not that creative. I ripped mine from Wikipedia, instead.
And I found it surprisingly consistent with what I remember
having learnt in those English lessons at school, long ago, btw.

Your recent postings indicate that you've written me off as a
troll, and just play your "confuse-a-troll" program on me.

0
Reply avl1 (2748) 3/4/2011 2:21:29 PM

Andreas Leitgeb wrote:
> Lew <lew@lewscanon.com> wrote:
>> On Mar 3, 8:29 am, Andreas Leitgeb <a...@gamma.logic.tuwien.ac.at>
>> wrote:
>>> Lew <no...@lewscanon.com> wrote:
>>>> On 02/26/2011 09:51 AM, Wanja Gayk wrote:
>>>>> In article<ik98h3$fk...@news.albasani.net>, no...@lewscanon.com says...
>>>>>> You base that on zero evidence, only your own assumptions.
>>>>>> I, on the other  hand, assume the OP meant precisely what he wrote.
>>>>> ..on zero evidence.
>>>> Huh?  He wrote it.  That's not "zero" evidence.
>>> That ${someone} wrote ${something} is not "evidence" for
>>> that ${someone} actually meant ${something}.

Certainly it is, unless you're a solipsist. It's not proof (for any
number of reasons, mostly epistemological, phenomenological, and
psychological), but it is evidence.

> Your definition of "evidence" seem to be incompatible.

Your use of "incompatible" has the wrong arity. It's a comparative
attribute.

> Wikipedia says:
>  "Evidence in its broadest sense includes everything that is
>   used to determine or demonstrate the truth of an assertion.
>   [...]
>   Evidence is the currency by which one fulfills the burden
>   of proof."

Wikipedia is neither the arbiter of the English language nor an
authority on epistemological foundation. I don't know whether you did
a poor job of quoting whatever article that comes from, or whether the
article in question is poorly written; but that's not a useful
definition of "evidence" in relation to the interpretation of a
written statement.

Under any useful theory of the interpretation of writing - from the
most bluntly realist, intentionalist claims that an utterance means
what its author believes it means, to the most deferred, displaced,
non-transmissive ends of poststructuralism and neopragmatism - must
hold that the utterance is in some way *evidence* of an
interpretation, and the outcome of interpretation is meaning.

Even under Derrida's model of writing as the trace of an
eternally-deferred meaning; even under Lacan's locating the origin of
writing in the unconscious (and so original meaning is largely
inaccessible to the author); even under Foucault's rejection of the
author-function; even under Rorty's rejection of the model of language
as a channel for the transmission of an idea. Under all of these,
parole is still evidence of meaning.

Whether that meaning is the facade of a meaning that inheres in the
author's conscious thought is another question - that one's been
fought over endlessly since at least the beginning of the twentieth
century (and sporadically before that, probably since people first had
the leisure time to worry about inconsequentials). But if you accept
the axioms that 1) someone created the utterance and 2) that person
did so under the influence of meaning, then the utterance must be
*evidence* of that meaning. (It could be misleading, misinterpreted,
damaged, etc. But it's still evidence of that meaning.)

> Oh, and by your own logic&terms, we have now strong "evidence",
> that you *meant* to create the new word "forwhat"...

Evidence. Not "strong" evidence. Why? Because we can assign
probabilities to features of the surface form of the utterance. In
fact we have to; that's how we're able to process natural language at
all, with its ambiguities and errors.

-- 
Michael Wojcik
Micro Focus
Rhetoric & Writing, Michigan State University
0
Reply mwojcik (1879) 3/4/2011 9:10:02 PM

On Mar 4, 4:10=A0pm, Michael Wojcik <mwoj...@newsguy.com> wrote:
> Andreas Leitgeb wrote:
> > Lew <l...@lewscanon.com> wrote:
> >> On Mar 3, 8:29 am, Andreas Leitgeb <a...@gamma.logic.tuwien.ac.at>
> >> wrote:
> >>> Lew <no...@lewscanon.com> wrote:
> >>>> On 02/26/2011 09:51 AM, Wanja Gayk wrote:
> >>>>> In article<ik98h3$fk...@news.albasani.net>, no...@lewscanon.com say=
s...
> >>>>>> You base that on zero evidence, only your own assumptions.
> >>>>>> I, on the other =A0hand, assume the OP meant precisely what he wro=
te.
> >>>>> ..on zero evidence.
> >>>> Huh? =A0He wrote it. =A0That's not "zero" evidence.
> >>> That ${someone} wrote ${something} is not "evidence" for
> >>> that ${someone} actually meant ${something}.
>
> Certainly it is, unless you're a solipsist. It's not proof (for any
> number of reasons, mostly epistemological, phenomenological, and
> psychological), but it is evidence.
>
> > Your definition of "evidence" seem to be incompatible.
>
> Your use of "incompatible" has the wrong arity. It's a comparative
> attribute.
>
> > Wikipedia says:
> > =A0"Evidence in its broadest sense includes everything that is
> > =A0 used to determine or demonstrate the truth of an assertion.
> > =A0 [...]
> > =A0 Evidence is the currency by which one fulfills the burden
> > =A0 of proof."
>
> Wikipedia is neither the arbiter of the English language nor an
> authority on epistemological foundation. I don't know whether you did
> a poor job of quoting whatever article that comes from, or whether the
> article in question is poorly written; but that's not a useful
> definition of "evidence" in relation to the interpretation of a
> written statement.
>
> Under any useful theory of the interpretation of writing - from the
> most bluntly realist, intentionalist claims that an utterance means
> what its author believes it means, to the most deferred, displaced,
> non-transmissive ends of poststructuralism and neopragmatism - must
> hold that the utterance is in some way *evidence* of an
> interpretation, and the outcome of interpretation is meaning.
>
> Even under Derrida's model of writing as the trace of an
> eternally-deferred meaning; even under Lacan's locating the origin of
> writing in the unconscious (and so original meaning is largely
> inaccessible to the author); even under Foucault's rejection of the
> author-function; even under Rorty's rejection of the model of language
> as a channel for the transmission of an idea. Under all of these,
> parole is still evidence of meaning.
>
> Whether that meaning is the facade of a meaning that inheres in the
> author's conscious thought is another question - that one's been
> fought over endlessly since at least the beginning of the twentieth
> century (and sporadically before that, probably since people first had
> the leisure time to worry about inconsequentials). But if you accept
> the axioms that 1) someone created the utterance and 2) that person
> did so under the influence of meaning, then the utterance must be
> *evidence* of that meaning. (It could be misleading, misinterpreted,
> damaged, etc. But it's still evidence of that meaning.)
>
> > Oh, and by your own logic&terms, we have now strong "evidence",
> > that you *meant* to create the new word "forwhat"...
>
> Evidence. Not "strong" evidence. Why? Because we can assign
> probabilities to features of the surface form of the utterance. In
> fact we have to; that's how we're able to process natural language at
> all, with its ambiguities and errors.
>

Brilliant.  Fucking brilliant.  You are a master, M. Wojcik.  I
learned a great deal from this post.

--
Lew
0
Reply lew (2468) 3/4/2011 10:26:51 PM

Michael Wojcik <mwojcik@newsguy.com> wrote:
> Andreas Leitgeb wrote:
>>>> That ${someone} wrote ${something} is not "evidence" for
>>>> that ${someone} actually meant ${something}.

I clarified that I considered evidence to be a synonym of proof.
As it isn't (so far three posters seem to agree on that it isn't.
I've yet to meet a native English speaker that I really trust to
confirm it, but I'll pretend to be convinced for now for the sake
of this discussion), there's no sense in judging my statement as
if I had denied any indication-ship at all.

> [...]  Under all of these, parole is still evidence of meaning.

It is! I'm not changing my mind here, just correcting my vocabulary.

What's still open, and where I'm sure that I disagree at least with
Lew, is, how to weigh that particular evidence against the already
mentioned counter-indications drawn from context.

>> Oh, and by your[Lew's] own logic&terms, we have now strong
>> "evidence", that you *meant* to create the new word "forwhat"...
> Evidence. Not "strong" evidence.

Lew appeared very confident about the OP meaning to write about
String-compatible user defined types String1 and String2, so 
with this mindset, usage of "forwhat" would have to be really
strong evidence, too.  Hardly to anyone else, though.

0
Reply avl1 (2748) 3/4/2011 10:56:56 PM

Andreas Leitgeb wrote:
> Lew appeared very confident about the OP meaning to write about
> String-compatible user defined types String1 and String2, so
> with this mindset, usage of "forwhat" would have to be really
> strong evidence, too.  Hardly to anyone else, though.
>

That's a misinterpretation of what I said.

I never spoke to the strength of the evidence.  But the evidence was there, as 
I said and you finally conceded.

Programming is an art of precision.  If the OP had meant 'String' in his code, 
he should have said that.  The natural language "forwhat" is not a comparable 
error; rules of interpretation are different for natural language than for 
code.  As you no doubt realize but that it would interfere with your sophistry.

If the OP really did mean 'String', they were careless, just as I was with 
"forwhat".  But the former means a program crash, and the latter nearly nothing.

Given that the OP's post used 'String1' and 'String2' repeatedly, and that he 
was careful to use both, it was evident that the choice was deliberate, unlike 
with my typo.  A deliberately chosen parole carries more evidentiary weight 
than an accidentally chosen one.  Another point omitted in your sophistry.

Regardless, it's clear that you're arguing for the sake of arguing, misstating 
my position so that you can continue to argue it, and generally behaving very 
unlike your usual contributory self.

-- 
Lew
Honi soit qui mal y pense.
0
Reply noone7 (4050) 3/5/2011 12:35:29 AM

Lew <noone@lewscanon.com> wrote:
> But the evidence was there, as I said and you finally conceded.

I immediately conceded with the "indication" being there. It just
took me a while to accept that "evidence" really appears to be 
understood as a synonym of indication by more than just you alone,
despite wikipedia (possibly falsely) supporting my (old) understanding.

> Programming is an art of precision.

Programming is.
Asking a question here, otoh., is communication, not programming.
We're no AI-robots, but humans, and should be mentally able (even
if not always willing) to parse less than perfect problem-descriptions
and apply a good dose of experience and gut-feeling w.r.t what the
asker really might mean.

> If the OP had meant 'String' in his code, he should have said that.

There's some evidence (induced by that it just makes most sense to
assume it), that the appended numbers were neither carelessness
nor meant literally, but just a meta-syntax to *tag* each use of
String. As such, I found it impressively clear and concise.

> ... your usual contributory self.
Thanks at least for that last acknowledgement.

I haven't consciously left it. Casually, I feel like clarifying
misunderstandings between others. That it may happen that I
introduce even worse ones thereby, is at least not intended.

0
Reply avl1 (2748) 3/5/2011 1:59:25 AM
comp.lang.java.programmer 51710 articles. 37 followers. Post

35 Replies
374 Views

Similar Articles

[PageSpeed] 26

  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Java Collections List : Converting from List '<Column <String1, String2>>' to 'List <String1>'
I have a function that returns a list like this:- List <Column <String1, String2>> Next I want to pass this list to a 2nd function, but 2nd function just need= s a list which contains only 1st part (string1) of the Column(s) of the abo= ve list. So I want pass just this list to 2nd function:- List <String1> What would be the best way to do this ?? [my use case: Both the functions are from a library that I use to access da= tabase(Cassandra) for a web application. 1st function gives me a list of al= l columns which has two parts name(String1) and valu...

Java Collections List : Converting from List '<Column <String1, String2>>' to 'List <String1>'
I have a function that returns a list like this:- List <Column <String1, String2>> Next I want to pass this list to a 2nd function, but 2nd function just need= s a list which contains only 1st part (string1) of the Column(s) of the abo= ve list. So I want pass just this list to 2nd function:- List <String1> What would be the best way to do this ?? [my use case: Both the functions are from a library that I use to access da= tabase(Cassandra) for a web application. 1st function gives me a list of al= l columns which has two parts name(String1) and valu...

convert list of lists to list
Is there a way to convert list_of_listsA to list_of_listsB, where one list in listof lists A is one element of listB? list_of_listsA: [['klas*', '*', '*'], ['mooi*', '*', '*', '*'], ['koe'], ['arm*', '*', '*(haar)'], ['groei*', '*', '*', '*', '*']] listB: ['klas* * *', 'mooi* * * *, 'koe', 'arm* * * (haar)', 'groei* * * * *'] Thankx! antar2 wrote: > Is there a way to convert list_of_listsA to list_of_listsB, where one >...

Converting a list of lists to a single list
I think that itertools may be able to do what I want but I have not been able to figure out how. I want to convert an arbitrary number of lists with an arbitrary number of elements in each list into a single list as follows. Say I have three lists: [[A0,A1,A2], [B0,B1,B2] [C0,C1,C2]] I would like to convert those to a single list that looks like this: [A0,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A1,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2,A2,B0,C0,C1,C2,B1,C0,C1,C2,B2,C0,C1,C2] An easier way to visualize the pattern I want is as a tree. A0 B0 C0 C1 C2 B1 C0 C1 ...

List of lists of lists of lists...
I would like to have a list of lists N times deep, and my solution is (in pseudocode): def deep(x): a=[x] return a mylist=[] for N: mylist=deep(mylist) Is there a more elegant way to do it? The maine idea is: from a list having the numbre of steps along N dimensions, generate a list with an item at each possible point. Example 1: N=2 list=[2,3] result=[[1,2],[1,2],[1,2]] Example 2: N=3 list=[3,1,2] result=[[[1,2,3]],[[1,2,3]]] -- Ángel Gutiérrez Rodríguez - agr@fq.uniovi.es Instituto de Ciencia de los Materiales de Madrid - CSIC SpLine - European Syncrothorn Radiat...

converting a hash where the value is a list of lists to just a list
Hi All, I have a hash where the values are a list of lists. What I would like to do is convert this to a hash where the value is just a reference to an array that contains the list of lists. Below is my attempt to convert this to what I want, the problem is that I am loosing some people in the process! use strict; use warnings; use Data::Dumper; my %people = ( 'hillrich' => [ [5308125], [2053628], [5312468], [5312492] ], 'hsieh' => [ [5312182], [5312613], [5312517] ], 'prakash' => [], 'florencb' => [ [1420688], [1420596]...

list of lists of lists ....
Hi, I have a list of data (type A) my list can includes element of type A or a lists, these list can includes element of type A or a lists, and so on ... is there a simple way to obtain a single list of all the elemets of type A ? thanks yomgui I forgot the most important, I am looking for a non recursive method. thanks yomgui yomgui wrote: > > Hi, > > I have a list of data (type A) > my list can includes element of type A or a lists, > these list can includes element of type A or a lists, and so on ... > > is there a simple way to obtain a single list of all...

Sort a List, in a List of Lists of Lists
Dear Mathgroup, I have a lsit of Lists of Lists: {{{1,2},{2,1},{1,1}},{{1,1},{1,1},{1,2}},{{2,1},{2,2},{1,2}},{{2,2},{1,2},{2,2}},{{1,1},{2,1},{1,2}},{{1,2},{2,2},{2,2}}} I would like to sort the elements in the lowest level of brackets to give {{{1, 2}, {1, 2}, {1, 1}}, {{1, 1}, {1, 1}, {1, 2}}, {{1, 2}, {2, 2}, {1, 2}}, {{2, 2}, {1, 2}, {2, 2}}, {{1, 1}, {1, 2}, {1, 2}}, {{1, 2}, {2, 2}, {2, 2}}} i.e retaining the same structure with the paired elements in the original order. I can't seem to get the syntax right to do this apart from the obvious {{Sort[{1,...

Howto: extract a 'column' from a list of lists into a new list?
I'm writing some routines for handling dBASE files. I've got a table (DBF file) object & field object already defined, and after opening the file, I can get the field info like this: >>> tbl.Fields() [('STOCKNO', 'C', 8, 0), ('DACC', 'C', 5, 0), ('DEALERACCE', 'C', 30, 0), ('D-ACCRTL', 'C', 9, 0), ('D-ACCCST', 'C', 9, 0)] What I would like to do is be able to extract the field names into a single, separate list. It should look like: ['STOCKNO', 'DACC', 'DEALERACCE',...

converting a list to keyed list
I need to convert the following list to a keyed list, so that the key value pair can be parsed at ease. Please let me know the easiest way - List - string " Adjacency cacSipAdj2 (SIP) Status: Attached Signaling address: 88.88.127.113:5060 Signaling-peer: 88.88.127.114:5060 Force next hop: No Account: CAC-Sip-Adj2 Group: In header profile: Default Out header profile: Default In method profile: Default ...

converting lists to strings to lists
hi, i'm doing some udp stuff and receive strings of the form '0.870000 0.250000 0.790000;\n' what i'd need though is a list of the form [0.870000 0.250000 0.790000] i got to the [0:-3] part to obtain a string '0.870000 0.250000 0.790000' but i can't find a way to convert this into a list. i tried eval() but this gives me the following error: Traceback (most recent call last): File "<stdin>", line 1, in ? File "<string>", line 1 .870000 0.250000 0.79000 and i have the same problem the other way round. e.g. i have a list whic...

Excel: Convert a single list into multiple columns?
I have a long list of names, sorted alphabetically, in a single column. What I want to do is separate the single column into two columns. For Example: Here is what I have: Bob Chris Dave Ernie Frank Gus Harold Irvine ect... Here is what I want: Page 1 Bob Frank Chris Gus Dave Harold Ernie Irvine Also, the list contains about 300 names. Is there any way I can divide the results so the names are printed alphabetically per page? What I mean is, page #1 might look like the example above (B thru I), and then page two would continue al...

Passing a Java collection object (List) to a SQLJ based stored procedure
Hello, I am trying to pass a java.util.List consisting of Hashtables to a SQLJ based stored procedure. Have anyone evet done this ? Maybe serializing the List object and using setBytes() method of CallableStatement solves the problem. At SQLJ side, I will deserialize it. Is this applicable and is there any other way ? Regards. Umut Ceyhan ...

convert list of tuples into several lists
Hi, I can find examples to convert lists into a list of tuples like: >>> map(None,[1,2,3],[4,5,6]) [(1,4),(2,5),(3,6)] but how is it done vice versa? Oliver zip(*[(1,4),(2,5),(3,6)]) -- Regards, Diez B. Roggisch Diez B. Roggisch wrote: > zip(*[(1,4),(2,5),(3,6)]) > Thanks :) I knew it must be simple. The asterics - thing was new to me. By the way: What is faster? this: z = [(1,4),(2,5),(3,6) a,b = zip(*[(x[0], x[0]-x[1]) for x in z]) or: a = [] b = [] for x in z: a.append(x[0]) b.append(x[0]-x[1]) I guess first, isn't it? Oliver Oliver Eichler a �cri...

Converting a list of strings into a list of integers?
Hi, Is there such a thing in the language, or do I have to invent it myself? I came up with the following: # options.modus_list contains, e.g., "[2,3,4]" # (a string from the command line) # MODUS_LIST contains, e.g., [2,4,8,16] # (i.e., a list of integers) if options.modus_list: intTmp = [] modTmp = options.modus_list[1:-1] for itm in modTmp: intTmp.append(int(itm)) MODUS_LIST = intTmp There are probably never more than maybe between one to four items in the options.modus_list, and its contents as integers should...

Converting a flat list to a list of tuples
Say you have a flat list: ['a', 1, 'b', 2, 'c', 3] How do you efficiently get [['a', 1], ['b', 2], ['c', 3]] I was thinking of something along the lines of: for (key,number) in list: print key, number but it's not working... Thank you metiu uitem wrote: > Say you have a flat list: > ['a', 1, 'b', 2, 'c', 3] > > How do you efficiently get > [['a', 1], ['b', 2], ['c', 3]] That's funny, I thought your subject line said 'list of tuples'. I'll answer the que...

Convert string list to number list
On importing a space delimited text file, I have an extracted list of zero-padded two-digit integers in the form: Amylist{"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"} How do I convert these to real numbers or integers? Thanks - Kurt I have reviewed the Mathe...

How to convert a list of strings into a list of variables
How would you convert a list of strings into a list of variables using the same name of the strings? So, ["red", "one", "maple"] into [red, one, maple] Thanks for any help! On Thu, Aug 18, 2011 at 10:57 AM, noydb <jenn.duerr@gmail.com> wrote: > How would you convert a list of strings into a list of variables using > the same name of the strings? > > So, ["red", "one", "maple"] into [red, one, maple] Why would you want to? On Aug 18, 11:12=A0am, David Robinow <drobi...@gmail.com> wrote: > On Thu, Aug 18...

Matrix (list-in-list), how to get a column?
Good afternoon, I have some data that looks like this: data = [[1, 2], [3, 4], [5, 6]] I want to send columns 1 and 2 to a function as two variables, say "plot(col1,col2)". I can get a row by data[r], but how do I get a column? data[:][c] would have been my guess, but that returns the same list as data[r]. I can solve this with two additional lists and a for loop, but that seems like an ugly hack. Five additional lines just seems clumsy. :-) Is there a more elegant solution than this? col1 = [] col2 = [] for i in range(len(data)): col1 += [a[i][0]] col2 += [a[i][1]] /Arv...

Converting 2D Lists to 3D lists
Hello Everyone, I want to know if there is a way to convert a 2D lists to 3D Lists. Below is the example list in list form: SampleList3D = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -.75}}} I want the list to be intact but add 5 at the end of each sublist; This is how I want it to look: {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, {0.5, -.75, 5}}} I also want to be able do the same as above but add 3 this time to the second column. This is how it should look. {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, {0.5, -.75...

Convert 3D list to 2D list
Hello, How can I convert a matrix that is currently 3-D into a matrix that is only 2-D? Currently, I have a 1x1x47 matrix and would like to make it 1x47 so I can plot it. Is there a way to remove the extra dimension? Or copy the values into a new matrix? Thanks, Madison On 3/23/2014 4:10 PM, Madison wrote: > Hello, > > How can I convert a matrix that is currently 3-D into a matrix >that is only 2-D? Currently, I have a 1x1x47 matrix and would like >to make it 1x47 so I can plot it. Is there a way to remove the >extra dimension? Or copy the values into a new mat...

Re: Sort a List, in a List of Lists of Lists
On 11/13/10 at 12:59 AM, leigh.pascoe@inserm.fr wrote: >I have a lsit of Lists of Lists: >{{{1,2},{2,1},{1,1}},{{1,1},{1,1},{1,2}},{{2,1},{2,2},{1,2}},{{2,2}, >{1,2},{2,2}},{{1,1},{2,1},{1,2}},{{1,2},{2, 2},{2,2}}} >I would like to sort the elements in the lowest level of brackets to >give >{{{1, 2}, {1, 2}, {1, 1}}, {{1, 1}, {1, 1}, {1, 2}}, {{1, 2}, {2, >2}, {1, 2}}, {{2, 2}, {1, 2}, {2, 2}}, {{1, 1}, {1, 2}, {1, 2}}, >{{1, 2}, {2, 2}, {2, 2}}} >i.e retaining the same structure with the paired elements in the >original order. I can't seem...

convert list of strings to set of regexes; convert list of strings to trie
Hello, I need a function that converts a list into a set of regexes. Like so: string_list = ["blaa", "blab", "raaa", "rabb"] print string_list2regexes(string_list) This should return something like: ["bla(a|b)", "ra(aa|bb)"] I am aware of the fact that converting the list to a *trie* would almost do the job. But I couldn't find anything about Python modules that produce tries. Are there any modules that I could use? Or do I have to implement it myself? Klaus [Klaus Neuner] > I need a function that converts a li...

List of Atom or List of List??
how can detect some element of list is list o Atom?? for example when i try head (head p1) where p1=[[1,2],2] return 1 but when try head (head p1) where p1=[1,2] it returns Error plz help me..it my project and i have just 2 hours..:( i want to replace on Atom by another in list..for example: replace 1 2 [1,2] => [2,2] but sometime i have replace 1 2 [[1,2],2]=>[[2,2],2] i want to detect if first element of list is list then recurcively call head on that element.. is there any solutions?? On 8 Apr 2007 02:46:25 -0700, kheirandish.amin@gmail.com wrote: >how can detect some eleme...

How to have a list of lists (or array of lists)
Hi, I want to have many lists, such as list0, list1, list2, ..., each one holding different number of items. Is there something like list[0] list[1] list[2] so that I can iterate through this list of lists? Thanks! bahoo On Apr 3, 7:12 pm, "bahoo" <b83503...@yahoo.com> wrote: > Hi, > > I want to have many lists, such as list0, list1, list2, ..., each one > holding different number of items. > Is there something like > list[0] > list[1] > list[2] > > so that I can iterate through this list of lists? > > Thanks! > bahoo listOfLists = [...