Posts

Showing posts with the label multidimensional-array

Creating a dynamic list from a 2D array (Angular)

Image
Clash Royale CLAN TAG #URR8PPP Creating a dynamic list from a 2D array (Angular) I'm trying to figure out how to make a ul of items from a 2D array. I have a 2D array. I'm trying to implement a UL where each IL is a separate row from the 2D array. The 2D array is retrieved from service.ts. Then the service delivers the 2D array to a component via a subscriber. I'm not to sure how to go about this. The idea is depicted below: Object. 1 Answer 1 The array you get from service.ts , make sure you assign it to a field inside you *.component.ts file. Then in your component.html file, you can iterate over this array with an *ngFor service.ts *.component.ts component.html *ngFor E.g <ul> <li *ngFor="let row of array">{{row}}</li> </ul> By clicking "Post Your Answer", you acknowledge that you have read our...

Check if multiple dimension Python array is empty

Image
Clash Royale CLAN TAG #URR8PPP Check if multiple dimension Python array is empty I have a function that can return randomly shaped array like: [[1], 2, [[3, 4], , [[5]]] I need to check if the result array is empty and I can't use numpy or any other third party library. Unfortunately, if : ... >>> False which is fine, but if [,]:... >>> True and I want this result to be false, so I came up with this: def isEmpty(a): return all([isEmpty(b) for b in a]) if isinstance(a, list) else False Is there a built in way to get this result ? If not this post might be usefull to someone somehow. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.