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 Egg() {...} | |
| // the curry func | |
| function prepareCooking(cook) { | |
| return function(egg1) { | |
| return function(egg2) { | |
| return function(egg3) { | |
| return function(egg4) { | |
| return cook(egg1, egg2, egg3, egg4) | |
| } |
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
| let collect = start(new Egg()) | |
| collect = collect(new Egg()) | |
| collect = collect(new Egg()) |
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 prepareCooking(cook) { | |
| return function(egg1) { | |
| return function(egg2) { | |
| return function(egg3) { | |
| // HERE | |
| return function(egg4) { | |
| return cook(egg1, egg2, egg3, egg4) | |
| } | |
| } | |
| } |
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 curry(fn) { | |
| return function curried() { | |
| const args = Array.prototype.slice.call(arguments) | |
| const done = args.length >= fn.length | |
| if (done) { | |
| return fn.apply(this, args) | |
| } else { | |
| return function() { | |
| const args2 = Array.prototype.slice.call(arguments) | |
| return curried.apply(this, args.concat(args2)) |
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 curry = (fn) => { | |
| return function curried(...args) { | |
| const done = args.length >= fn.length | |
| if (done) { | |
| return fn.apply(this, args) | |
| } else { | |
| return (...args2) => curried.apply(this, [...args, ...args2]) | |
| } | |
| } | |
| } |
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 curry = (fn) => { | |
| return function curried(...args) { | |
| const done = args.length >= fn.length | |
| if (done) { | |
| return fn.apply(this, args) | |
| } else { | |
| return (...args2) => curried.apply(this, [...args, ...args2]) | |
| } | |
| } | |
| } |
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
| {"lastUpload":"2021-05-14T14:01:55.433Z","extensionVersion":"v3.4.3"} |
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 novice = { username: 'henry123', level: 10, hp: 100 } | |
| function transform(target) { | |
| return Object.assign(target, { | |
| fireBolt(player) { | |
| player.hp -= 15 | |
| return this | |
| }, | |
| }) | |
| } |
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 novice = { username: 'henry123', level: 10, hp: 100 } | |
| function transform(target) { | |
| return { | |
| ...target, | |
| fireBolt(player) { | |
| player.hp -= 15 | |
| return this | |
| }, | |
| } |
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
| import React from 'react' | |
| import { | |
| EditIcon, | |
| DeleteIcon, | |
| ResetIcon, | |
| TrashIcon, | |
| UndoIcon, | |
| } from '../lib/icons' | |
| import * as utils from '../utils |