This is a summary of the "Learn You A Haskell" online book under http://learnyouahaskell.com/chapters.
- Haskell is a functional programming language.
SUFFIXES = {1000: ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], | |
1024: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']} | |
def approximate_size(size, a_kilobyte_is_1024_bytes=True): | |
'''Convert a file size to human-readable form. | |
Keyword arguments: | |
size -- file size in bytes | |
a_kilobyte_is_1024_bytes -- if True (default), use multiples of 1024 | |
if False, use multiples of 1000 |
This is a summary of the "Learn You A Haskell" online book under http://learnyouahaskell.com/chapters.
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
Should be work with 0.18
Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !
myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))