Ansible with_items refer to different list - ansible-2.x

I would appreciate if someone could help me.
I have the following task:
https://gist.github.com/anonymous/1f33615218086b9a0512
following variables:
https://gist.github.com/anonymous/42c4a0f46871e36c4761
I would like in first case item[0] to loop first list,
and with item[1] to loop over the second list.
Thanks,

I think what you want is a nested loop
Using with_items, as you have it now, will just combine the lists and iterate over each item sequentially. As you can see in your debug outputm item[0] and item1 are just the first and second characters in current loop item string

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)}

How to do a loop for each item in a list? VB.NET

How do i do a loop for each item in a list?
I tried to do a For Each but then i could not get it past that.
i know it has to end with: Next but i dont know how to make a loop for each item, which is the main problem.
to give further information, i am writing an item of the list to a text file, and every item it needs to get the "n" item of the list and write it.
What i am doing:
For Each In listclass.List
usernameFile.WriteLine(usersClass.UsersName(n))
usernameFile.Close()
Next```
Have you taken a look at the VB.net microsoft docs? It appears you're missing the "Element" portion in your first "For Each..." statement. Microsoft Docs. Also, try searching for existing answers on stackoverflow. Often times, a question has already been answered as in the following: Looping in VB.NET

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:]

Iteration of array in Liquid

I'm using an analog of Shopify and I'm stuck with syntax of Liquid.
I need to output in the template the field with an id product[product_field_values_attributes][][value]
So I need to write a loop to get the i value of this array.
I'm confused with this empty element in the brackets.
I've looked through the examples of loop syntax in Liquid but all of those arrays are simple and they are not my case.
For example, the Title field has id product[title] and in Liquid template i call this variable product.title and it works fine.
But all my tries to write a loop for this array failed.
Please, help to write a loop to get the values of the array stated above.
Try outputting the array directly onto the page using {{ product }} or {{ product[product_field_values_attributes] }} somewhere in the HTML. That will do a JSON-like string representation of the array. From there you can figure out what the keys for the array are.
I'm not sure what you're saying about the i value. You don't reference i anywhere else in your question. If you can clarify that then we can see if something can be done about it.

Add element to next unused index - C

I'm sure others have already asked this, but is it possible to insert an element into the next available index of an array without using a for-loop to find that index first? Almost like a list.add() function but for arrays in C.
no, you will have to loop through the array.
If it's really list functionality you want you could implement a simple linked list instead of using arrays, for example like this: http://www.cprogramming.com/tutorial/c/lesson15.html

Resources