Get data from generic list between some alphabet - generic-list

I have one generic list , from which I want to get those items only which are starting between some alphabets.
Supoose I have listitems like ABC,DEF,Zebra,Important,Check,Jump
From this I want to get listitem which starts from alphabet between A to C
This should return ABC,Check only..
Thanking in advance.

List stringlist= new List() {"ABC","BCD", "CDE","DEF","EFG","PQR","IJK","QRS","XYZ"};
List temp=stringlist.FindAll(s=>Enumerable.Range(65,3).Contains(s.toUpper()[0]));
change the range as per your requirement.

Related

How to compile a list of other lists by checkbox?

I'm trying to write a cell formula which can essentially create a single playlist of songs.
Currently the songs are grouped by decade, but I'd like to be able to see a single list of everything that has been ticked.
I tried an array formula, but it only returned the first ticked song. Plus not sure how to make the array formula include the adjacent lists.
I tried a FILTER function, it works for one list of songs, but I don't know how to get it to append the other lists on the end.
Could I use a QUERY function? Not sure how though.
Many thanks!
try:
={"LIST"; FILTER({C:C; F:F}; {B:B; E:E}=TRUE)}
awesome question! You were super close in your filter example, one more filter in your array would've done it :)
Example Image:
Example Formula:
={"LIST"; FILTER(C:C, B:B=TRUE); FILTER(F:F, E:E=TRUE)}

index of a word changed after the array was converted to lower case, and saved as a new list

so I converted my array to lower case using HashSet, and saved it to a new Array, However, this changed the index of words, and now my dialog box description of an item and a webpage that has to load on itemClick are all off. please, help!
Ihad to convert caps as i needed to get the exact corresponding data for the item on click. Thanks in advance!
If the language you're using is Java, you can simply use toLowerCase method. Try using this.
tried many different ways! but found this code from the post from 2010!! and it worked like a charm!!!!
`public static void replace(List strings){
ListIterator iterator = strings.listIterator();
while (iterator.hasNext())
{
iterator.set(iterator.next().toLowerCase());
}
}
thank you, Mathew from 2010!!!

Separating different parts of a list

I'm working with a pretty large list and I need to separate the list from lst[7] and up. How do I go about this? Here's the code / lists specifically (My apologies for not formatting the list in the code snippet way, this was a lot easier to read this way):
Judging by your list, looks like everything you want will have 'year' as part of it's first element.
So do this:
your_new_list = [l for l in lst if 'year' in l[0]]
your_new_list will be a list of list that only the list that you want.
This will filter for all the list in your list of list where the first element has 'year' in the string.
You just need the 7th elements and up from this list? I can't fully understand your last line. But if that's the case:
lst2 = lst1[7:]
edit:
It actually looks like you want to skip the first nine lists, though, so it should be:
lst2 = lst1[9:]

AS3: Array Guidance

Ok so I'll start off with what I am trying to do here with an Array. So I have a grid of 1-59, Now the user gets to pick 5 numbers. When the user picks a number it goes into a box in the top corner of the screen. So what I am trying to make an Array for is a user selects a number it goes into the first box then the second number goes into the second one and so on.
I am still new to AS3 and I have been reading about Arrays, but I'm still stuck on how to do this or even start it. Thanks for the help guys.
Well, you know you need five elements in the array, so:
private var m_arr:Array = new Array(5);
That'll get you an array with five elements, which can be filled later.
Next, it sounds like you need to keep track of which number gets picked first, which number gets picked second, and so on. So let's make a place-holder and initialize it to 0:
private var m_iNextElement:int = 0;
Then whenever they select a number, just say:
m_arr[m_iNextElement] = theNumber;
m_iNextElement++;
As Fygo already mentioned, you could just do this instead:
private var m_arr:Array = new Array();
.
.
.
m_arr.push(number1);
.
.
.
m_arr.push(number2); // and so on
Whichever is better depends on the situation. Last, you need to find some way to tie each element of the array to a graphical element of some sort. There are many ways you could do this, but if you're using MXML, you could consider making the array bindable:
[Bindable]
private var m_arr:Array = new Array(5);
Then you could have in the MXML:
<local:Box id="box1" text="{m_arr[0]}" />
<local:Box id="box2" text="{m_arr[1]}" /> <!-- etc. -->
var nums:Array = [];
//when the user picks whatever number, you call:
nums.push(the_number_that_the_user_selected);
Is that all you wanted to achieve?
Actionscript offers your basic index array [] and associative array {} as well as some fancier ones like vector. It sounds like you simply need to do something with an index array.
Check out this tutorial, it's all about shuffling arrays. http://code.tutsplus.com/tutorials/quick-tip-how-to-randomly-shuffle-an-array-in-as3--active-8776

How do I determine if an item in a array begins with a specific letter

I've got a simple java assignment. I need to list all the names of the pupils whose names start with the letter "P" (the pupils names are in an array called names).I have tried using if(names[m].startsWith("P")); but I haven't got it to work yet.Is there anyway to solve this problem?
Thanks in advance.
Try using a charAt(int index) String method. The if–statement would look like:
...
if(names[m].charAt(0) == 'P')
...

Resources