Skip to content

Instantly share code, notes, and snippets.

@caervs
caervs / andy.md
Last active August 16, 2017 02:31

Functional Programming Exercises

Some terminology

When writing code in python, we're used to calling things functions when in reality what we're writing are procedures.

What's the difference?

Procedures and Functions

import math
def side_length(n):
"""
return the side length of a polygon inscribed in a unit circle
The number of sides that the polygon has is (2 ** n) * 6
"""
if n == 0:
import functools
import itertools
import operator
class AlgebraicStructure(object):
def __init__(self, elements, *operations):
if len(operations) != len(self.operation_names):
raise ValueError
self.elements = elements
### Keybase proof
I hereby claim:
* I am caervs on github.
* I am rabrams (https://keybase.io/rabrams) on keybase.
* I have a public key whose fingerprint is 89BB 66FA 2BF6 FA19 A63D 9A46 02C3 E5D5 AB1D 877F
To claim this, I am signing this object: