Travis build: 90

This commit is contained in:
30secondsofcode
2019-09-19 17:45:43 +00:00
parent 8e26881b4a
commit a790c30ad8
3 changed files with 57 additions and 0 deletions

View File

@ -39,6 +39,7 @@
* [`every`](#every)
* [`every_nth`](#every_nth)
* [`filter_non_unique`](#filter_non_unique)
* [`flatten`](#flatten)
* [`group_by`](#group_by)
* [`has_duplicates`](#has_duplicates)
* [`head`](#head)
@ -482,6 +483,27 @@ filter_non_unique([1, 2, 2, 3, 4, 4, 5]) # [1, 3, 5]
<br>[⬆ Back to top](#contents)
### flatten
Flattens a list of lists once.
Use nested list comprehension to extract each value from sub-lists in order.
```py
def flatten(lst):
return [x for y in lst for x in y]
```
<details>
<summary>Examples</summary>
```py
flatten([[1,2,3,4],[5,6,7,8]]) # [1, 2, 3, 4, 5, 6, 7, 8]
```
</details>
<br>[⬆ Back to top](#contents)
### group_by
Groups the elements of a list based on the given function.

View File

@ -402,6 +402,21 @@
"hash": "05679ae115d276830ec769a04b0800d92eabc6a09678fc1a9cf6013c813cc650"
}
},
{
"id": "flatten",
"type": "snippetListing",
"title": "flatten",
"attributes": {
"text": "Flattens a list of lists once.\n\nUse nested list comprehension to extract each value from sub-lists in order.\n\n",
"tags": [
"list",
"intermediate"
]
},
"meta": {
"hash": "49b4f976c9050c9cb6fe038653fc3dbc88135086255c06c4f46b746b21bfb544"
}
},
{
"id": "gcd",
"type": "snippetListing",

View File

@ -532,6 +532,26 @@
"hash": "05679ae115d276830ec769a04b0800d92eabc6a09678fc1a9cf6013c813cc650"
}
},
{
"id": "flatten",
"title": "flatten",
"type": "snippet",
"attributes": {
"fileName": "flatten.md",
"text": "Flattens a list of lists once.\n\nUse nested list comprehension to extract each value from sub-lists in order.\n\n",
"codeBlocks": {
"code": "def flatten(lst):\n return [x for y in lst for x in y]",
"example": "flatten([[1,2,3,4],[5,6,7,8]]) # [1, 2, 3, 4, 5, 6, 7, 8]"
},
"tags": [
"list",
"intermediate"
]
},
"meta": {
"hash": "49b4f976c9050c9cb6fe038653fc3dbc88135086255c06c4f46b746b21bfb544"
}
},
{
"id": "gcd",
"title": "gcd",