nested-lists

How to round every float in a nested list of tuples

徘徊边缘 提交于 2020-02-22 07:38:54
问题 I have a list of coordinates like this: [[(-88.99716274669669, 45.13003508233472), (-88.46889143213836, 45.12912220841379), (-88.47075415770517, 44.84090409706577), (-88.75033424251002, 44.84231949526811), (-88.75283245650954, 44.897062864942406), (-88.76794136151051, 44.898020801741716), (-88.77994787408718, 44.93415662283567), (-88.99624763048942, 44.93474749747682), (-88.99716274669669, 45.13003508233472)]] Or like this: [[(-88.99716274669669, 45.13003508233472)], [(-88.46889143213836, 45

How to round every float in a nested list of tuples

可紊 提交于 2020-02-22 07:38:48
问题 I have a list of coordinates like this: [[(-88.99716274669669, 45.13003508233472), (-88.46889143213836, 45.12912220841379), (-88.47075415770517, 44.84090409706577), (-88.75033424251002, 44.84231949526811), (-88.75283245650954, 44.897062864942406), (-88.76794136151051, 44.898020801741716), (-88.77994787408718, 44.93415662283567), (-88.99624763048942, 44.93474749747682), (-88.99716274669669, 45.13003508233472)]] Or like this: [[(-88.99716274669669, 45.13003508233472)], [(-88.46889143213836, 45

append a list element-wise to elements of a nested list in R

纵然是瞬间 提交于 2020-02-15 10:20:08
问题 I'm new to R and still trying to get my head around the apply family instead of using loops. I have two lists, one nested, the other not, both composed of characters: >lst1 <- list(c("ABC", "DEF", "GHI"), c("JKL", "MNO", "PQR")) >lst2 <- c("abc", "def") I would like to create a third list such that each element of lst2 is appended as the last element of the respective sublist in lst1. The desired output looks like this: >lst3 [[1]] [1] "ABC" "DEF" "GHI" "abc" [[2]] [1] "JKL" "MNO" "PQR" "def"

How to make my function move through two lists at once?

允我心安 提交于 2020-01-25 06:51:29
问题 I'm trying to make a function that will take a list of lists of Int s as an input, and adds +1 every time it runs into a number bigger or equal to 10. I added -20 on each side so xc can start at 0. Example what should happen after the function runs into first '10': [[-20,-20, 0, 0, 0, 0, 0, 0, 0,-20,-20], [-20,-20, 0,10, 1, 0, 0, 0, 0,-20,-20], [-20,-20, 1, 1, 1, 0,10, 0, 0,-20,-20], [-20,-20, 0, 0, 0,10, 0, 0, 0,-20,-20], [-20,-20, 0, 0, 0, 0, 0, 0,10,-20,-20], [-20,-20,10,10,10, 0, 0, 0, 0,

android nested recyclerview

杀马特。学长 韩版系。学妹 提交于 2020-01-14 08:53:30
问题 I m trying to display nested recyclerview but the child items does not display. I want to display different items in all child view. I don't get a error, but the view is not refreshed. Here is my code can any one help. Thanks public class MainActivity extends ActionBarActivity { RecyclerView recyclerView; RootAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adapter = new RootAdapter(this

Creating a nested UL from flat array in PHP

醉酒当歌 提交于 2020-01-14 03:26:08
问题 This is an array that was built from a JSON file. What I want to do is create a unordered nested list. I have seen a lot of tutorials out there but they usually only work for a simple (id, parent id, name) layout. This array is more complicated than that which is why my attempts don't seem to work. This is the desired outcome: Standard I: Curriculum, Planning, and Assessment Indicator I-A. Curriculum & Planning I-A-1. Child and Adolescent Development content will go in here I-A-2. Child and

Processing a sub-list of variable size within a larger list

Deadly 提交于 2020-01-14 03:05:50
问题 I'm a biological engineering PhD student here trying to self-learn Python programming for use in automating a part of my research, but I've ran into a problem with processing sub-lists within a bigger list that I can't seem to solve. Basically, the goal of what I'm trying to do is write a small script that will process a CSV file containing a list of plasmid sequences that I'm building using various DNA assembly methods, and then spit out the primer sequences that I need to order in order to

Return nested list with nested level and value

不羁的心 提交于 2020-01-12 16:23:30
问题 I would like to visualize some deeply nested data using networkD3 . I can't figure out how to get the data into the right format before sending to radialNetwork . Here is some sample data: level <- c(1, 2, 3, 4, 4, 3, 4, 4, 1, 2, 3) value <- letters[1:11] where level indicates the level of the nest, and value is the name of the node. By using these two vectors, I need to get the data into the following format: my_list <- list( name = "root", children = list( list( name = value[1], ## a

Python: flatten nested lists with indices

别来无恙 提交于 2020-01-12 06:53:29
问题 Given a list of arbitrairly deep nested lists of arbitrary size, I would like an flat, depth-first iterator over all elements in the tree, but with path indicies as well such that: for x, y in flatten(L), x == L[y[0]][y[1]]...[y[-1]]. That is L = [[[1, 2, 3], [4, 5]], [6], [7,[8,9]], 10] flatten(L) should yield: (1, (0, 0, 0)), (2, (0, 0, 1)), (3, (0, 0, 2)), (4, (0, 1, 0)), (5, (0, 1, 1)), (6, (1, 0)), (7, (2, 0)), (8, (2, 1, 0)), (9, (2, 1, 1)), (10, (3,)) I made a recursive implementation

Python: flatten nested lists with indices

ぃ、小莉子 提交于 2020-01-12 06:53:27
问题 Given a list of arbitrairly deep nested lists of arbitrary size, I would like an flat, depth-first iterator over all elements in the tree, but with path indicies as well such that: for x, y in flatten(L), x == L[y[0]][y[1]]...[y[-1]]. That is L = [[[1, 2, 3], [4, 5]], [6], [7,[8,9]], 10] flatten(L) should yield: (1, (0, 0, 0)), (2, (0, 0, 1)), (3, (0, 0, 2)), (4, (0, 1, 0)), (5, (0, 1, 1)), (6, (1, 0)), (7, (2, 0)), (8, (2, 1, 0)), (9, (2, 1, 1)), (10, (3,)) I made a recursive implementation