This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorld: | |
def __init__(self, name): | |
self.name = name.capitalize() | |
def sayHi(self): | |
print "Hello " + self.name + "!" | |
hello = HelloWorld("world") | |
hello.sayHi() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorld: | |
def __init__(self, name): | |
self.name = name.capitalize() | |
def sayHi(self): | |
print "Hello " + self.name + "!" | |
hello = HelloWorld("world") | |
hello.sayHi() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export default () => <div/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Title = styled.h1` | |
font-size: 1.5em; | |
text-align: center; | |
color: palevioletred; | |
:hover { | |
color: red; | |
} | |
`; | |
// attrs, props, & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rootInstance = null; | |
function render(element, container) { | |
const prevInstance = rootInstance; | |
const nextInstance = reconcile(container, prevInstance, element); | |
rootInstance = nextInstance; | |
} | |
function reconcile(parentDom, instance, element) { | |
if (instance == null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import R from "ramda"; | |
var divisibleBy = R.curry(R.pipe(R.flip(R.modulo), R.equals(0))); | |
var fizzbuzz = R.map( | |
R.cond([ | |
[R.both(divisibleBy(3), divisibleBy(5)), R.always("FizzBuzz")], | |
[divisibleBy(3), R.always("Fizz")], | |
[divisibleBy(5), R.always("Buzz")], | |
[R.T, R.identity] | |
]) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FizzBuzz = ( | |
<map> | |
<cond concat> | |
<pair> | |
<both> | |
<DivisibleBy value={3} /> | |
<DivisibleBy value={5} /> | |
</both> | |
<always value="FizzBuzz" /> | |
</pair> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx run */ | |
function run(f, props, ...args) { | |
return R[f](...args); | |
} | |
var divisibleBy = ( | |
<curry> | |
<pipe> | |
<flip> | |
<modulo /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Hypotenuse = ({ values }) => ( | |
<Sqrt> | |
<Sum>{values.map(v => <Pow exponent={2}>{v}</Pow>)}</Sum> | |
</Sqrt> | |
); | |
console.log(<Hypotenuse values={[3, 4, 5]} />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Sum = (...args) => args.reduce((a, b) => a + b, 0); | |
const Pow = ({ exponent }, base) => Math.pow(base, exponent); | |
const Sqrt = x => Math.sqrt(x); | |
const Hypotenuse = ({ a, b }) => ( | |
<Sqrt> | |
<Sum> | |
<Pow exponent={2}>{a}</Pow> | |
<Pow exponent={2}>{b}</Pow> | |
</Sum> |