Hello everybody. I have a list of sublists, and each of these sublists contains anywhere from 3 to 5 items - the number of items varies pretty randomly between sublists. I want to delete the last item from each sublist. How can I do that?
The description of the node is jumbled… If you hover over the “amount” input, you’ll see the explanation that if you use a negative number, the items will be removed from the end of the list.
With “List.Map”, we perform the function to each sub-list in the input list.
It does! One last issue. I have one list of 495 points, and I have another list of 495 sublists, and each sublist has 3-6 items. What I want to do is take each point from the first list, and make it the first item of each respective sublist in the second list (in other words, the first item on List A would become the first item of Sublist 1 in List B). All I can think of is the method below, but I’d need a way to combine every two sublists into one. Is there a way to insert items directly into the first spot of sublists? Or is there a way to do this sublist combination method I’m thinking about? Thank you again!
You’ll need to use “List.Combine”, which is very similar to “List.Map” in theory. The only difference being that you can specify an argument for each variable in the function. In your case the function will be “List.AddItemToFront”. It needs two variables to work - an item to be added and a list to perform the action on. In your case each item in listA is the “item” variable and listB is the “list” variable.
Also note the “Flatten” node. Most functions won’t need it there, “List.AddItemToFront” is an exception due to the way the node works. For example “List.AddItemToEnd” doesn’t need it: