Spaces:
Running
Running
Commit
·
662415d
1
Parent(s):
8177ad2
fixing typo
Browse files
functional_programming/06_applicatives.py
CHANGED
|
@@ -218,7 +218,7 @@ def _(mo):
|
|
| 218 |
return curr
|
| 219 |
```
|
| 220 |
|
| 221 |
-
/// attention | minimal
|
| 222 |
|
| 223 |
- `pure`
|
| 224 |
- `apply`
|
|
@@ -317,7 +317,7 @@ def _(mo):
|
|
| 317 |
```
|
| 318 |
|
| 319 |
- `apply` should apply a list of functions to a list of values
|
| 320 |
-
- you can think of this as cartesian product,
|
| 321 |
|
| 322 |
The implementation is:
|
| 323 |
"""
|
|
@@ -817,7 +817,7 @@ def _(IO):
|
|
| 817 |
return ""
|
| 818 |
return IO.lift(
|
| 819 |
lambda: lambda s1: lambda: lambda s2: s1 + "\n" + s2,
|
| 820 |
-
IO.pure(input(
|
| 821 |
IO.pure(get_chars(n - 1)),
|
| 822 |
)
|
| 823 |
return (get_chars,)
|
|
@@ -881,7 +881,7 @@ def _(mo):
|
|
| 881 |
def _(IO, sequenceL):
|
| 882 |
def get_chars_sequenceL(n: int = 3):
|
| 883 |
return sequenceL(
|
| 884 |
-
[IO.pure(input(f"input the {i}
|
| 885 |
)
|
| 886 |
return (get_chars_sequenceL,)
|
| 887 |
|
|
@@ -1015,7 +1015,7 @@ def _(mo):
|
|
| 1015 |
r"""
|
| 1016 |
## Instance: ListMonoidal
|
| 1017 |
|
| 1018 |
-
- `unit` should simply return a
|
| 1019 |
|
| 1020 |
```haskell
|
| 1021 |
ListMonoidal.unit() => [()]
|
|
|
|
| 218 |
return curr
|
| 219 |
```
|
| 220 |
|
| 221 |
+
/// attention | minimal implementation requirement
|
| 222 |
|
| 223 |
- `pure`
|
| 224 |
- `apply`
|
|
|
|
| 317 |
```
|
| 318 |
|
| 319 |
- `apply` should apply a list of functions to a list of values
|
| 320 |
+
- you can think of this as cartesian product, concatenating the result of applying every function to every value
|
| 321 |
|
| 322 |
The implementation is:
|
| 323 |
"""
|
|
|
|
| 817 |
return ""
|
| 818 |
return IO.lift(
|
| 819 |
lambda: lambda s1: lambda: lambda s2: s1 + "\n" + s2,
|
| 820 |
+
IO.pure(input("input line")),
|
| 821 |
IO.pure(get_chars(n - 1)),
|
| 822 |
)
|
| 823 |
return (get_chars,)
|
|
|
|
| 881 |
def _(IO, sequenceL):
|
| 882 |
def get_chars_sequenceL(n: int = 3):
|
| 883 |
return sequenceL(
|
| 884 |
+
[IO.pure(input(f"input the {i}th str") for i in range(1, n + 1))], IO
|
| 885 |
)
|
| 886 |
return (get_chars_sequenceL,)
|
| 887 |
|
|
|
|
| 1015 |
r"""
|
| 1016 |
## Instance: ListMonoidal
|
| 1017 |
|
| 1018 |
+
- `unit` should simply return a empty tuple wrapper in a list
|
| 1019 |
|
| 1020 |
```haskell
|
| 1021 |
ListMonoidal.unit() => [()]
|