Travis build: 90
This commit is contained in:
22
README.md
22
README.md
@ -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.
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
Reference in New Issue
Block a user