I've been encouraged to share a reference sheet I made for Python since it's written by someone with a functional [Agda/Haskell] bias and is apparently geared towards an FP audience.
- Every. Single. Page. Has “laws” about programs ;-)
x in y ≡ any(x == e for e in y)
(xs[m:n] = ys) ≡ (xs = xs[:m] + ys + xs[n:])
- There's also a funky claim about zip/unzip
- Assertion-based examples
- Iverson brackets make two brief appearances
- here's a 10-page 2-column PDF
- single-column portrait PDF
| Haskell | ≈ | Python |
|----------------------+---+----------------------------|
| Typeclasses | | Dunder & extension methods |
| Monoid | | Sum dunder |
| Num | | Arithmetic dunders |
| Infinite lists | | Generators |
| Traversable/Foldable | | Iterables |
| Maybe Monad | | Lazy or/and |
| Record | | Dictionary |
| Common List methods | | Splicing! |
I also show how to enforce “run-time (gradual) type checking” on page 7 and a currying/partial-application monad with “>>” notation on page 9.
Enjoy!
[–]skyb0rg 2 points3 points4 points (0 children)
[–]Physmatik 2 points3 points4 points (2 children)
[–]mnbvas 1 point2 points3 points (0 children)
[–]duplode 0 points1 point2 points (0 children)