hidden examples
This commit is contained in:
26
README.md
26
README.md
@ -65,7 +65,7 @@ def chunk(arr, size):
|
||||
chunk([1,2,3,4,5],2) # [[1,2],[3,4],5]
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
### compact
|
||||
|
||||
Removes falsey values from a list.
|
||||
@ -88,7 +88,7 @@ def compact(arr):
|
||||
compact([0, 1, False, 2, '', 3, 'a', 's', 34]) # [ 1, 2, 3, 'a', 's', 34 ]
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
### count_occurences
|
||||
|
||||
:information_source: Already implemented via `list.count()`.
|
||||
@ -115,7 +115,7 @@ def count_occurences(arr, val):
|
||||
count_occurrences([1, 1, 2, 1, 2, 3], 1) # 3
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
### deep_flatten
|
||||
|
||||
Deep flattens a list.
|
||||
@ -151,7 +151,7 @@ def deep_flatten(arr):
|
||||
deep_flatten([1, [2], [[3], 4], 5]) # [1,2,3,4,5]
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
### difference
|
||||
|
||||
Returns the difference between two arrays.
|
||||
@ -174,7 +174,7 @@ def difference(a, b):
|
||||
difference([1, 2, 3], [1, 2, 4]) # [3]
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
### shuffle
|
||||
|
||||
:information_source: The same algorithm is already implemented via `random.shuffle`.
|
||||
@ -210,7 +210,7 @@ foo = [1,2,3]
|
||||
shuffle(foo) # [2,3,1] , foo = [1,2,3]
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
### spread
|
||||
|
||||
Implements javascript's spread syntax as a function. Flattens the list(non-deep) and returns an list.
|
||||
@ -238,7 +238,7 @@ def spread(arg):
|
||||
spread([1,2,3,[4,5,6],[7],8,9]) # [1,2,3,4,5,6,7,8,9]
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
### zip
|
||||
|
||||
:information_source: Already implemented via `itertools.zip_longest()`
|
||||
@ -271,7 +271,7 @@ zip(['a'], [1, 2], [True, False]) # [['a', 1, True], [None, 2, False]]
|
||||
zip(['a'], [1, 2], [True, False], fill_value = '_') # [['a', 1, True], ['_', 2, False]]
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
## :scroll: String
|
||||
|
||||
### count_vowels
|
||||
@ -300,7 +300,7 @@ count_vowels('foobar') # 3
|
||||
count_vowels('gym') # 0
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
## :heavy_division_sign: Math
|
||||
|
||||
### gcd
|
||||
@ -349,7 +349,7 @@ def gcd(*args):
|
||||
gcd(8,36) # 4
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
### lcm
|
||||
|
||||
Returns the least common multiple of two or more numbers.
|
||||
@ -398,7 +398,7 @@ lcm(12, 7) # 84
|
||||
lcm([1, 3, 4], 5) # 60
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
### max_n
|
||||
|
||||
Returns the `n` maximum elements from the provided list. If `n` is greater than or equal to the provided list's length, then return the original list(sorted in descending order).
|
||||
@ -428,7 +428,7 @@ max_n([1, 2, 3]) # [3]
|
||||
max_n([1, 2, 3], 2) # [3,2]
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
### min_n
|
||||
|
||||
Returns the `n` minimum elements from the provided list. If `n` is greater than or equal to the provided list's length, then return the original list(sorted in ascending order).
|
||||
@ -457,7 +457,7 @@ min_n([1, 2, 3]) # [1]
|
||||
min_n([1, 2, 3], 2) # [1,2]
|
||||
|
||||
```
|
||||
<details>
|
||||
</details>
|
||||
|
||||
## Credits
|
||||
|
||||
|
||||
@ -49,5 +49,5 @@ for category in tag_dict:
|
||||
someFile = open("snippets/" + snippet + '.md')
|
||||
fileData = someFile.read()
|
||||
codeParts = re.split(codeRe,fileData)
|
||||
toAppend += codeParts[0] + f'```py{codeParts[1]} \n ```' +codeParts[2] + f'<details><summary>View Examples</summary>\n\n```py\n{codeParts[3]}\n```\n<details>' + '\n'
|
||||
toAppend += codeParts[0] + f'```py{codeParts[1]} \n ```' +codeParts[2] + f'<details><summary>View Examples</summary>\n\n```py\n{codeParts[3]}\n```\n</details>' + '\n'
|
||||
open("README.md",'w').write(start+toAppend+'\n'+end)
|
||||
|
||||
Reference in New Issue
Block a user