This file contains hidden or 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
function fail(makeErrorData = (c, e) => ({ ...e })) { | |
return { | |
target: "#payment.failed", | |
actions: assign({ | |
error_code: (c, e) => e.type, | |
error_data: makeErrorData, | |
}), | |
}; | |
} |
This file contains hidden or 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 orderPage = Machine({ | |
id: "order", | |
initial: "base", | |
context: { | |
refund: null, | |
}, | |
states: { | |
base: { | |
on:{ | |
REFUND: 'refund', |
This file contains hidden or 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
This file contains hidden or 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
struct MyStruct { | |
value: u8 | |
} | |
impl MyStruct { | |
pub fn Create() -> MyStruct { | |
MyStruct { | |
value: 7u8 | |
} | |
} |
This file contains hidden or 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 MyClass { | |
public: | |
MyClass() { | |
value = 7; | |
} | |
int value; | |
}; |
This file contains hidden or 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 exampleFunction1 = (n) => { | |
if (!predicate1) { | |
return 7 | |
} | |
if (predicate2) { | |
sideEffect1(n) | |
return transformer2(transformer1(arg1, arg2, n), arg1) | |
} else { | |
return transformer2(transformer5(n), arg2) |
This file contains hidden or 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 exampleFunction1 = (n) => { | |
if (predicate1) { | |
if (predicate2) { | |
sideEffect1(n) | |
const value1 = transformer1(arg1, arg2, n) | |
return transformer2(value1, arg1) | |
} else { | |
let value2 = 0 | |
while (somePredicate()) { |
This file contains hidden or 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
Count | Generated angle | Angle modulo 360 (hue) | Output colour | |
---|---|---|---|---|
0 | 0 | 0 | red | |
1 | 137 | 137 | green | |
2 | 274 | 274 | purple | |
3 | 411 | 51 | yellow | |
4 | 548 | 188 | cyan |
This file contains hidden or 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 StudentClass = function(){ | |
this.name = "Some default name"; | |
this.age = undefined; | |
this.address = {}; | |
}; | |
var StudentClassBuilder = new BuilderDecorator(StudentClass); | |
var student = new StudentClassBuilder() | |
.name("John") | |
.age(17) |
This file contains hidden or 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
// Telescoping constructor | |
var employee = Immutable(new Employee("John", "01234 56432", "07922344500", "53 Oakland Road", "Devon", "UK")); | |
// With builder | |
var employee = new EmployeeBuilder() | |
.name("John") | |
.phone("01234 56432") | |
.mobile("07922344500") | |
.addresslineone("53 Oakland Road") | |
.county("Devon") |
NewerOlder