{"id":29126332,"url":"https://github.com/zero-to-mastery/js_fun_practice","last_synced_at":"2025-06-29T23:04:38.192Z","repository":{"id":37411714,"uuid":"134188447","full_name":"zero-to-mastery/JS_Fun_Practice","owner":"zero-to-mastery","description":"A list of small \u0026 fun functional programming exercises in JavaScript","archived":false,"fork":false,"pushed_at":"2024-01-10T22:50:31.000Z","size":551,"stargazers_count":674,"open_issues_count":22,"forks_count":545,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-01-10T23:55:53.297Z","etag":null,"topics":["hacktoberfest","javascript-practice-problems","javascript-puzzles"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zero-to-mastery.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-05-20T21:31:52.000Z","updated_at":"2024-01-05T18:40:21.000Z","dependencies_parsed_at":"2024-01-10T23:48:21.941Z","dependency_job_id":"a59137f7-b29c-4d0a-9d3a-017008de622a","html_url":"https://github.com/zero-to-mastery/JS_Fun_Practice","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/zero-to-mastery/JS_Fun_Practice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-to-mastery%2FJS_Fun_Practice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-to-mastery%2FJS_Fun_Practice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-to-mastery%2FJS_Fun_Practice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-to-mastery%2FJS_Fun_Practice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zero-to-mastery","download_url":"https://codeload.github.com/zero-to-mastery/JS_Fun_Practice/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-to-mastery%2FJS_Fun_Practice/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262680553,"owners_count":23347597,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","javascript-practice-problems","javascript-puzzles"],"created_at":"2025-06-29T23:04:35.486Z","updated_at":"2025-06-29T23:04:38.178Z","avatar_url":"https://github.com/zero-to-mastery.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-function-fun\n\nA list of small \u0026 fun functional programming exercises in JavaScript.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md).\n\n## Testing\n\n### To test the functions:\n1. Run \u003ccode\u003enpm install\u003c/code\u003e to install the dependencies (need node.js for npm). If you don't have node please visit the [Node JS](https://nodejs.org/en/) website to download. It is recommended to download the LTS version.\n2. Change \u003ccode\u003efilename\u003c/code\u003e in \u003ccode\u003etest/tests.js\u003c/code\u003e to the name of your solution file (optional).\n3. Make sure your solution file is in the \u003ccode\u003eSolutions\u003c/code\u003e folder.\n4. Make sure your function names match the ones listed below as you're coding them.\n5. At the bottom of your solution file, copy and paste the following code:\n```js\nmodule.exports = {\n    identity,\n    addb,\n    subb,\n    mulb,\n    minb,\n    maxb,\n    add,\n    sub,\n    mul,\n    min,\n    max,\n    addRecurse,\n    mulRecurse,\n    minRecurse,\n    maxRecurse,\n    not,\n    acc,\n    accPartial,\n    accRecurse,\n    fill,\n    fillRecurse,\n    set,\n    identityf,\n    addf,\n    liftf,\n    pure,\n    curryb,\n    curry,\n    inc,\n    twiceUnary,\n    doubl,\n    square,\n    twice,\n    reverseb,\n    reverse,\n    composeuTwo,\n    composeu,\n    composeb,\n    composeTwo,\n    compose,\n    limitb,\n    limit,\n    genFrom,\n    genTo,\n    genFromTo,\n    elementGen,\n    element,\n    collect,\n    filter,\n    filterTail,\n    concatTwo,\n    concat,\n    concatTail,\n    gensymf,\n    gensymff,\n    fibonaccif,\n    counter,\n    revocableb,\n    revocable,\n    extract,\n    m,\n    addmTwo,\n    addm,\n    liftmbM,\n    liftmb,\n    liftm,\n    exp,\n    expn,\n    addg,\n    liftg,\n    arrayg,\n    continuizeu,\n    continuize,\n    vector,\n    exploitVector,\n    vectorSafe,\n    pubsub,\n    mapRecurse,\n    filterRecurse,\n};\n```\n\n6. You can comment out any function names in the \u003ccode\u003emodule.exports\u003c/code\u003e that you haven't written yet, but a lot of the tests depend on previous functions to run properly so it's safer to write the functions in order.\n7. Finally, \u003ccode\u003enpm run test\u003c/code\u003e to run the tests.\n\n## Functions\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#identity\"\u003eidentity(x)\u003c/a\u003e ⇒ \u003ccode\u003eany\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eidentity\u003c/code\u003e that\ntakes an argument and returns\nthat argument\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#addb\"\u003eaddb(a, b)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a binary function \u003ccode\u003eaddb\u003c/code\u003e\nthat takes two numbers and returns\ntheir sum\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#subb\"\u003esubb(a, b)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a binary function \u003ccode\u003esubb\u003c/code\u003e\nthat takes two numbers and returns\ntheir difference\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#mulb\"\u003emulb(a, b)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a binary function \u003ccode\u003emulb\u003c/code\u003e\nthat takes two numbers and returns\ntheir product\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#minb\"\u003eminb(a, b)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a binary function \u003ccode\u003eminb\u003c/code\u003e\nthat takes two numbers and returns\nthe smaller one\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#maxb\"\u003emaxb(a, b)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a binary function \u003ccode\u003emaxb\u003c/code\u003e\nthat takes two numbers and returns\nthe larger one\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#add\"\u003eadd(...nums)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eadd\u003c/code\u003e that\nis generalized for any\namount of arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#sub\"\u003esub(...nums)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003esub\u003c/code\u003e that\nis generalized for any\namount of arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#mul\"\u003emul(...nums)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003emul\u003c/code\u003e that\nis generalized for any\namount of arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#min\"\u003emin(...nums)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003emin\u003c/code\u003e that\nis generalized for any\namount of arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#max\"\u003emax(...nums)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003emax\u003c/code\u003e that\nis generalized for any\namount of arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#addRecurse\"\u003eaddRecurse(...nums)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eaddRecurse\u003c/code\u003e that\nis the generalized \u003ccode\u003eadd\u003c/code\u003e function\nbut uses recursion\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#mulRecurse\"\u003emulRecurse(...nums)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003emulRecurse\u003c/code\u003e that\nis the generalized \u003ccode\u003emul\u003c/code\u003e function\nbut uses recursion\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#minRecurse\"\u003eminRecurse(...nums)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eminRecurse\u003c/code\u003e that\nis the generalized \u003ccode\u003emin\u003c/code\u003e function\nbut uses recursion\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#maxRecurse\"\u003emaxRecurse(...nums)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003emaxRecurse\u003c/code\u003e that\nis the generalized \u003ccode\u003emax\u003c/code\u003e function\nbut uses recursion\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#not\"\u003enot(func)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003enot\u003c/code\u003e that\ntakes a function and returns\nthe negation of its result\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#acc\"\u003eacc(func, initial)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eacc\u003c/code\u003e that\ntakes a function and an\ninitial value and returns\na function that runs the\ninitial function on each\nargument, accumulating the\nresult\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#accPartial\"\u003eaccPartial(func, start, end)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eaccPartial\u003c/code\u003e that\ntakes in a function, a start index,\nand an end index, and returns a\nfunction that accumulates a subset\nof its arguments by applying the\ngiven function to all elements\nbetween start and end.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#accRecurse\"\u003eaccRecurse(func, initial)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eaccRecurse\u003c/code\u003e that\ndoes what \u003ccode\u003eacc\u003c/code\u003e does but uses recursion\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#fill\"\u003efill(num)\u003c/a\u003e ⇒ \u003ccode\u003earray\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003efill\u003c/code\u003e that\ntakes a number and returns\nan array with that many\nnumbers equal to the given\nnumber\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#fillRecurse\"\u003efillRecurse(num)\u003c/a\u003e ⇒ \u003ccode\u003earray\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003efillRecurse\u003c/code\u003e that\ndoes what \u003ccode\u003efill\u003c/code\u003e does but uses recursion\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#set\"\u003eset(...args)\u003c/a\u003e ⇒ \u003ccode\u003earray\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eset\u003c/code\u003e that\nis given a list of arguments\nand returns an array with\nall duplicates removed\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#identityf\"\u003eidentityf(x)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eidentityf\u003c/code\u003e\nthat takes an argument and\nreturns a function that\nreturns that argument\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#addf\"\u003eaddf(a)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eaddf\u003c/code\u003e that\nadds from two invocations\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#liftf\"\u003eliftf(binary)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eliftf\u003c/code\u003e that\ntakes a binary function, and\nmakes it callable with two\ninvocations\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#pure\"\u003epure(x, y)\u003c/a\u003e ⇒ \u003ccode\u003earray\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a \u003ca href=\"https://en.wikipedia.org/wiki/Pure_function\"\u003epure\u003c/a\u003e function \u003ccode\u003epure\u003c/code\u003e that\nis a wrapper arround the impure\nfunction \u003ccode\u003eimpure\u003c/code\u003e\u003c/p\u003e\n\n```js\nfunction impure(x) {\n  y++;\n  z = x * y;\n}\n\nvar y = 5, z;\n\nimpure(20);\nz; // 120\n\nimpure(25);\nz; // 175\n```\n\n\u003cdt\u003e\u003ca href=\"#curryb\"\u003ecurryb(binary, a)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003ecurryb\u003c/code\u003e that\ntakes a binary function and\nan argument, and returns a\nfunction that can take a\nsecond argument\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#curry\"\u003ecurry(func, ...outer)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003ecurry\u003c/code\u003e that\nis generalized for any amount\nof arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#inc\"\u003einc(x)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWithout writting any new functions,\nshow multiple ways to create the \u003ccode\u003einc\u003c/code\u003e\nfunction\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#twiceUnary\"\u003etwiceUnary(binary)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003etwiceUnary\u003c/code\u003e\nthat takes a binary function\nand returns a unary function\nthat passes its argument to\nthe binary function twice\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#doubl\"\u003edoubl(x)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eUse the function \u003ccode\u003etwiceUnary\u003c/code\u003e to\ncreate the \u003ccode\u003edoubl\u003c/code\u003e function\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#square\"\u003esquare(x)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eUse the function \u003ccode\u003etwiceUnary\u003c/code\u003e to\ncreate the \u003ccode\u003esquare\u003c/code\u003e function\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#twice\"\u003etwice(x)\u003c/a\u003e ⇒ \u003ccode\u003eany\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003etwice\u003c/code\u003e that\nis generalized for any amount\nof arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#reverseb\"\u003ereverseb(binary)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003ereverseb\u003c/code\u003e that\nreverses the arguments of a\nbinary function\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#reverse\"\u003ereverse(func)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003ereverse\u003c/code\u003e that\nis generalized for any amount\nof arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#composeuTwo\"\u003ecomposeuTwo(unary1, unary2)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003ecomposeuTwo\u003c/code\u003e that\ntakes two unary functions and\nreturns a unary function that\ncalls them both\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#composeu\"\u003ecomposeu(...funcs)\u003c/a\u003e ⇒ \u003ccode\u003eany\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003ecomposeu\u003c/code\u003e that\nis generalized for any amount\nof arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#composeb\"\u003ecomposeb(binary1, binary2)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003ecomposeb\u003c/code\u003e that\ntakes two binary functions and\nreturns a function that calls\nthem both\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#composeTwo\"\u003ecomposeTwo(func1, func2)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003ecomposeTwo\u003c/code\u003e that\ntakes two functions and returns a\nfunction that calls them both\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#compose\"\u003ecompose(...funcs)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003ecompose\u003c/code\u003e that\ntakes any amount of functions\nand returns a function that takes\nany amount of arguments and gives\nthem to the first function, then\nthat result to the second function\nand so on\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#limitb\"\u003elimitb(binary, lmt)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003elimitb\u003c/code\u003e\nthat allows a binary function\nto be called a limited number\nof times\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#limit\"\u003elimit(func, lmt)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003elimit\u003c/code\u003e that\nis generalized for any amount\nof arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#genFrom\"\u003egenFrom(x)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003egenFrom\u003c/code\u003e that\nproduces a generator that will\nproduces a series of values\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#genTo\"\u003egenTo(gen, lmt)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003egenTo\u003c/code\u003e that\ntakes a generator and an end\nlimit, and returns a generator\nthat will produce numbers up\nto that limit\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#genFromTo\"\u003egenFromTo(start, end)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003egenFromTo\u003c/code\u003e that\nproduces a generator that will\nproduce values in a range\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#elementGen\"\u003eelementGen(array, gen)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eelementGen\u003c/code\u003e that\ntakes an array and a generator\nand returns a generator that will\nproduce elements from the array\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#element\"\u003eelement(array, gen)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eelement\u003c/code\u003e that is a\nmodified \u003ccode\u003eelementGen\u003c/code\u003e function so that\nthe generator argument is optional.\nIf a generator is not provided, then\neach of the elements of the array\nwill be produced.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#collect\"\u003ecollect(gen, array)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003ecollect\u003c/code\u003e that takes a\ngenerator and an array and produces\na function that will collect the results\nin the array\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#filter\"\u003efilter(gen, predicate)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003efilter\u003c/code\u003e that takes a\ngenerator and a predicate and produces\na generator that produces only the\nvalues approved by the predicate\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#filterTail\"\u003efilterTail(gen, predicate)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003efilterTail\u003c/code\u003e that uses\ntail-recursion to perform the filtering\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#concatTwo\"\u003econcatTwo(gen1, gen2)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003econcatTwo\u003c/code\u003e that takes\ntwo generators and produces a generator\nthat combines the sequences\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#concat\"\u003econcat(...gens)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003econcat\u003c/code\u003e that\nis generalized for any amount\nof arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#concatTail\"\u003econcatTail(...gens)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003econcatTail\u003c/code\u003e that uses\ntail-recursion to perform the concating\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#gensymf\"\u003egensymf(symbol)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003egensymf\u003c/code\u003e that\nmakes a function that generates\nunique symbols\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#gensymff\"\u003egensymff(unary, seed)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003egensymff\u003c/code\u003e that\ntakes a unary function and a\nseed and returns a \u003ccode\u003egensymf\u003c/code\u003e\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#fibonaccif\"\u003efibonaccif(first, second)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003efibonaccif\u003c/code\u003e that\nreturns a generator that will\nreturn the next fibonacci number\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#counter\"\u003ecounter(i)\u003c/a\u003e ⇒ \u003ccode\u003eobject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003ecounter\u003c/code\u003e that\nreturns an object containing\ntwo functions that implement\nan up/down counter, hiding\nthe counter\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#revocableb\"\u003erevocableb(binary)\u003c/a\u003e ⇒ \u003ccode\u003eobject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003erevocableb\u003c/code\u003e\nthat takes a binary function, and\nreturns an object containing an\n\u003ccode\u003einvoke\u003c/code\u003e function that can invoke a\nfunction and a \u003ccode\u003erevoke\u003c/code\u003e function\nthat disables the \u003ccode\u003einvoke\u003c/code\u003e function\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#revocable\"\u003erevocable(func)\u003c/a\u003e ⇒ \u003ccode\u003eobject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003erevocable\u003c/code\u003e that\nis generalized for any amount of\narguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#extract\"\u003eextract(array, prop)\u003c/a\u003e ⇒ \u003ccode\u003earray\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eextract\u003c/code\u003e that\ntakes an array of objects and an\nobject property name and converts\neach object in the array by\nextracting that property\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#m\"\u003em(value, source)\u003c/a\u003e ⇒ \u003ccode\u003eobject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003em\u003c/code\u003e that\ntakes a value and an\noptional source string\nand returns them in an\nobject\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#addmTwo\"\u003eaddmTwo(m1, m2)\u003c/a\u003e ⇒ \u003ccode\u003eobject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eaddmTwo\u003c/code\u003e that\nadds two \u003ccode\u003em\u003c/code\u003e objects and\nreturns an \u003ccode\u003em\u003c/code\u003e object\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#addm\"\u003eaddm(...ms)\u003c/a\u003e ⇒ \u003ccode\u003eobject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eaddm\u003c/code\u003e that\nis generalized for any amount of\narguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#liftmbM\"\u003eliftmbM(binary, op)\u003c/a\u003e ⇒ \u003ccode\u003eobject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eliftmbM\u003c/code\u003e that\ntakes a binary function and\na string and returns a function\nthat acts on \u003ccode\u003em\u003c/code\u003e objects\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#liftmb\"\u003eliftmb(binary, op)\u003c/a\u003e ⇒ \u003ccode\u003eobject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eliftmb\u003c/code\u003e that\nis a modified function \u003ccode\u003eliftmbM\u003c/code\u003e\nthat can accept arguments that\nare either numbers or m objects\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#liftm\"\u003eliftm(func, op)\u003c/a\u003e ⇒ \u003ccode\u003eobject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eliftm\u003c/code\u003e that\nis generalized for any amount of\narguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#exp\"\u003eexp(value)\u003c/a\u003e ⇒ \u003ccode\u003eany\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eexp\u003c/code\u003e that\nevaluates simple array\nexpressions\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#expn\"\u003eexpn(value)\u003c/a\u003e ⇒ \u003ccode\u003eany\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eexpn\u003c/code\u003e\nthat is a modified \u003ccode\u003eexp\u003c/code\u003e that\ncan evaluate nested array\nexpressions\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#addg\"\u003eaddg(value)\u003c/a\u003e ⇒ \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003eundefined\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eaddg\u003c/code\u003e that\nadds from many invocations,\nuntil it sees an empty\ninvocation\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#liftg\"\u003eliftg(binary)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003eliftg\u003c/code\u003e that\nwill take a binary function\nand apply it to many invocations\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#arrayg\"\u003earrayg(value)\u003c/a\u003e ⇒ \u003ccode\u003earray\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003earrayg\u003c/code\u003e that\nwill build an array from many\ninvocations\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#continuizeu\"\u003econtinuizeu(unary)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003econtinuizeu\u003c/code\u003e\nthat takes a unary function\nand returns a function that\ntakes a callback and an\nargument\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#continuize\"\u003econtinuize(func)\u003c/a\u003e ⇒ \u003ccode\u003efunction\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eWrite a function \u003ccode\u003econtinuize\u003c/code\u003e\nthat takes a function and\nreturns a function that\ntakes a callback and arguments\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#vector\"\u003evector()\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eMake an array wrapper object\nwith methods \u003ccode\u003eget\u003c/code\u003e, \u003ccode\u003estore\u003c/code\u003e,\nand \u003ccode\u003eappend\u003c/code\u003e, such that an\nattacker cannot get access\nto the private array\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#exploitVector\"\u003eexploitVector()\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eLet\u0026#39;s assume your \u003ccode\u003evector\u003c/code\u003e\nimplementation looks like\nsomething like this:\u003c/p\u003e\n\n```js\nlet vector = () =\u003e {\n  let array = []\n  return {\n    append: (v) =\u003e array.push(v),\n    get: (i) =\u003e array[i],\n    store: (i, v) =\u003e array[i] = v\n  }\n}\n```\n\n\u003cp\u003eCan you spot any security concerns with\nthis approach? Mainly, can we get access\nto the \u003ccode\u003earray\u003c/code\u003e outside of \u003ccode\u003evector\u003c/code\u003e?\nNote\u003cem\u003e: the issue has nothing to do with\nprototypes and we can assume that global\nprototypes cannot be altered.\nHint\u003c/em\u003e: Think about using \u003ccode\u003ethis\u003c/code\u003e in a\nmethod invocation. Can we override a\nmethod of \u003ccode\u003evector\u003c/code\u003e?\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#vectorSafe\"\u003evectorSafe()\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eHow would you rewrite \u003ccode\u003evector\u003c/code\u003e to deal\nwith the issue from above?\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#pubsub\"\u003epubsub()\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eMake a function \u003ccode\u003epubsub\u003c/code\u003e that\nmakes a publish/subscribe object.\nIt will reliably deliver all\npublications to all subscribers\nin the right order.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#mapRecurse\"\u003emapRecurse(array, callback)\u003c/a\u003e ⇒ \u003ccode\u003earray\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eMake a function \u003ccode\u003emapRecurse\u003c/code\u003e that\nperforms a transformation for each\nelement of a given array, recursively\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#filterRecurse\"\u003efilterRecurse(array, predicate)\u003c/a\u003e ⇒ \u003ccode\u003earray\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eMake a function \u003ccode\u003efilterRecurse\u003c/code\u003e that\ntakes in an array and a predicate\nfunction and returns a new array by\nfiltering out all items using the\npredicate, recursively.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"identity\"\u003e\u003c/a\u003e\n\n## identity(x) ⇒ \u003ccode\u003eany\u003c/code\u003e\n\nWrite a function `identity` that\ntakes an argument and returns\nthat argument\n\n| Param | Type             |\n| ----- | ---------------- |\n| x     | \u003ccode\u003eany\u003c/code\u003e |\n\n**Example**\n\n```js\nidentity(3) // 3\n```\n\n\u003ca name=\"addb\"\u003e\u003c/a\u003e\n\n## addb(a, b) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a binary function `addb`\nthat takes two numbers and returns\ntheir sum\n\n| Param | Type                |\n| ----- | ------------------- |\n| a     | \u003ccode\u003enumber\u003c/code\u003e |\n| b     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\naddb(3, 4) // 3 + 4 = 7\n```\n\n\u003ca name=\"subb\"\u003e\u003c/a\u003e\n\n## subb(a, b) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a binary function `subb`\nthat takes two numbers and returns\ntheir difference\n\n| Param | Type                |\n| ----- | ------------------- |\n| a     | \u003ccode\u003enumber\u003c/code\u003e |\n| b     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nsubb(3, 4) // 3 - 4 = -1\n```\n\n\u003ca name=\"mulb\"\u003e\u003c/a\u003e\n\n## mulb(a, b) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a binary function `mulb`\nthat takes two numbers and returns\ntheir product\n\n| Param | Type                |\n| ----- | ------------------- |\n| a     | \u003ccode\u003enumber\u003c/code\u003e |\n| b     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nmulb(3, 4) // 3 * 4 = 12\n```\n\n\u003ca name=\"minb\"\u003e\u003c/a\u003e\n\n## minb(a, b) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a binary function `minb`\nthat takes two numbers and returns\nthe smaller one\n\n| Param | Type                |\n| ----- | ------------------- |\n| a     | \u003ccode\u003enumber\u003c/code\u003e |\n| b     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nminb(3, 4) // 3\n```\n\n\u003ca name=\"maxb\"\u003e\u003c/a\u003e\n\n## maxb(a, b) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a binary function `maxb`\nthat takes two numbers and returns\nthe larger one\n\n| Param | Type                |\n| ----- | ------------------- |\n| a     | \u003ccode\u003enumber\u003c/code\u003e |\n| b     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nmaxb(3, 4) // 4\n```\n\n\u003ca name=\"add\"\u003e\u003c/a\u003e\n\n## add(...nums) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a function `add` that\nis generalized for any\namount of arguments\n\n| Param   | Type                |\n| ------- | ------------------- |\n| ...nums | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nadd(1, 2, 4) // 1 + 2 + 4 = 7\n```\n\n\u003ca name=\"sub\"\u003e\u003c/a\u003e\n\n## sub(...nums) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a function `sub` that\nis generalized for any\namount of arguments\n\n| Param   | Type                |\n| ------- | ------------------- |\n| ...nums | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nsub(1, 2, 4) // 1 - 2 - 4 = -5\n```\n\n\u003ca name=\"mul\"\u003e\u003c/a\u003e\n\n## mul(...nums) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a function `mul` that\nis generalized for any\namount of arguments\n\n| Param   | Type                |\n| ------- | ------------------- |\n| ...nums | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nmul(1, 2, 4) // 1 * 2 * 4 = 8\n```\n\n\u003ca name=\"min\"\u003e\u003c/a\u003e\n\n## min(...nums) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a function `min` that\nis generalized for any\namount of arguments\n\n| Param   | Type                |\n| ------- | ------------------- |\n| ...nums | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nmin(1, 2, 4) // 1\n```\n\n\u003ca name=\"max\"\u003e\u003c/a\u003e\n\n## max(...nums) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a function `max` that\nis generalized for any\namount of arguments\n\n| Param   | Type                |\n| ------- | ------------------- |\n| ...nums | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nmax(1, 2, 4) // 4\n```\n\n\u003ca name=\"addRecurse\"\u003e\u003c/a\u003e\n\n## addRecurse(...nums) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a function `addRecurse` that\nis the generalized `add` function\nbut uses recursion\n\n| Param   | Type                |\n| ------- | ------------------- |\n| ...nums | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\naddRecurse(1, 2, 4) // 1 + 2 + 4 = 7\n```\n\n\u003ca name=\"mulRecurse\"\u003e\u003c/a\u003e\n\n## mulRecurse(...nums) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a function `mulRecurse` that\nis the generalized `mul` function\nbut uses recursion\n\n| Param   | Type                |\n| ------- | ------------------- |\n| ...nums | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nmulRecurse(1, 2, 4) // 1 * 2 * 4 = 8\n```\n\n\u003ca name=\"minRecurse\"\u003e\u003c/a\u003e\n\n## minRecurse(...nums) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a function `minRecurse` that\nis the generalized `min` function\nbut uses recursion\n\n| Param   | Type                |\n| ------- | ------------------- |\n| ...nums | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nminRecurse(1, 2, 4) // 1\n```\n\n\u003ca name=\"maxRecurse\"\u003e\u003c/a\u003e\n\n## maxRecurse(...nums) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWrite a function `maxRecurse` that\nis the generalized `max` function\nbut uses recursion\n\n| Param   | Type                |\n| ------- | ------------------- |\n| ...nums | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nmaxRecurse(1, 2, 4) // 4\n```\n\n\u003ca name=\"not\"\u003e\u003c/a\u003e\n\n## not(func) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `not` that\ntakes a function and returns\nthe negation of its result\n\n| Param | Type                  |\n| ----- | --------------------- |\n| func  | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nconst isOdd = (x) =\u003e x % 2 === 1\nconst isEven = not(isOdd)\nisEven(1) // false\nisEven(2) // true\n```\n\n\u003ca name=\"acc\"\u003e\u003c/a\u003e\n\n## acc(func, initial) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `acc` that\ntakes a function and an\ninitial value and returns\na function that runs the\ninitial function on each\nargument, accumulating the\nresult\n\n| Param   | Type                  |\n| ------- | --------------------- |\n| func    | \u003ccode\u003efunction\u003c/code\u003e |\n| initial | \u003ccode\u003eany\u003c/code\u003e      |\n\n**Example**\n\n```js\nlet add = acc(addb, 0)\nadd(1, 2, 4) // 7\n\nlet mul = acc(mulb, 1)\nmul(1, 2, 4) // 8\n```\n\n\u003ca name=\"accPartial\"\u003e\u003c/a\u003e\n\n## accPartial(func, start, end) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `accPartial` that\ntakes in a function, a start index,\nand an end index, and returns a\nfunction that accumulates a subset\nof its arguments by applying the\ngiven function to all elements\nbetween start and end.\n\n| Param | Type                  |\n| ----- | --------------------- |\n| func  | \u003ccode\u003efunction\u003c/code\u003e |\n| start | \u003ccode\u003enumber\u003c/code\u003e   |\n| end   | \u003ccode\u003enumber\u003c/code\u003e   |\n\n**Example**\n\n```js\nconst addSecondToThird = accPartial(add, 1, 3)\naddSecondToThird(1, 2, 4, 8) // [ 1, 6, 8 ]\n```\n\n\u003ca name=\"accRecurse\"\u003e\u003c/a\u003e\n\n## accRecurse(func, initial) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `accRecurse` that\ndoes what `acc` does but uses recursion\n\n| Param   | Type                  |\n| ------- | --------------------- |\n| func    | \u003ccode\u003efunction\u003c/code\u003e |\n| initial | \u003ccode\u003enumber\u003c/code\u003e   |\n\n**Example**\n\n```js\nlet add = accRecurse(addb, 0)\nadd(1, 2, 4) // 7\n\nlet mul = accRecurse(mulb, 1)\nmul(1, 2, 4) // 8\n```\n\n\u003ca name=\"fill\"\u003e\u003c/a\u003e\n\n## fill(num) ⇒ \u003ccode\u003earray\u003c/code\u003e\n\nWrite a function `fill` that\ntakes a number and returns\nan array with that many\nnumbers equal to the given\nnumber\n\n| Param | Type                |\n| ----- | ------------------- |\n| num   | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nfill(3) // [ 3, 3, 3 ]\n```\n\n\u003ca name=\"fillRecurse\"\u003e\u003c/a\u003e\n\n## fillRecurse(num) ⇒ \u003ccode\u003earray\u003c/code\u003e\n\nWrite a function `fillRecurse` that\ndoes what `fill` does but uses recursion\n\n| Param | Type                |\n| ----- | ------------------- |\n| num   | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nfillRecurse(3) // [ 3, 3, 3 ]\n```\n\n\u003ca name=\"set\"\u003e\u003c/a\u003e\n\n## set(...args) ⇒ \u003ccode\u003earray\u003c/code\u003e\n\nWrite a function `set` that\nis given a list of arguments\nand returns an array with\nall duplicates removed\n\n| Param   | Type             |\n| ------- | ---------------- |\n| ...args | \u003ccode\u003eany\u003c/code\u003e |\n\n**Example**\n\n```js\nlet oneAndTwo = set(1, 1, 1, 2, 2, 2) // [ 1, 2 ]\n```\n\n\u003ca name=\"identityf\"\u003e\u003c/a\u003e\n\n## identityf(x) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `identityf`\nthat takes an argument and\nreturns a function that\nreturns that argument\n\n| Param | Type             |\n| ----- | ---------------- |\n| x     | \u003ccode\u003eany\u003c/code\u003e |\n\n**Example**\n\n```js\nlet three = identityf(3)\nthree() // 3\n```\n\n\u003ca name=\"addf\"\u003e\u003c/a\u003e\n\n## addf(a) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `addf` that\nadds from two invocations\n\n| Param | Type                |\n| ----- | ------------------- |\n| a     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\naddf(3)(4) // 7\n```\n\n\u003ca name=\"liftf\"\u003e\u003c/a\u003e\n\n## liftf(binary) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `liftf` that\ntakes a binary function, and\nmakes it callable with two\ninvocations\n\n| Param  | Type                  |\n| ------ | --------------------- |\n| binary | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet addf = liftf(addb)\naddf(3)(4) // 7\n\nliftf(mulb)(5)(6) // 30\n```\n\n\u003ca name=\"pure\"\u003e\u003c/a\u003e\n\n## pure(x, y) ⇒ \u003ccode\u003earray\u003c/code\u003e\n\nWrite a [pure](https://en.wikipedia.org/wiki/Pure_function) function `pure` that\nis a wrapper arround the impure\nfunction `impure`\n\n```js\nfunction impure(x) {\n  y++;\n  z = x * y;\n}\n\nvar y = 5, z;\n\nimpure(20);\nz; // 120\n\nimpure(25);\nz; // 175\n```\n\n**Returns**: \u003ccode\u003earray\u003c/code\u003e - an array containing `y` and `z`\n\n| Param | Type                |\n| ----- | ------------------- |\n| x     | \u003ccode\u003enumber\u003c/code\u003e |\n| y     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\npure(20, 5) // [ 6, 120 ]\npure(25, 6) // [ 7, 175 ]\n```\n\n\u003ca name=\"curryb\"\u003e\u003c/a\u003e\n\n## curryb(binary, a) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `curryb` that\ntakes a binary function and\nan argument, and returns a\nfunction that can take a\nsecond argument\n\n| Param  | Type                  |\n| ------ | --------------------- |\n| binary | \u003ccode\u003efunction\u003c/code\u003e |\n| a      | \u003ccode\u003eany\u003c/code\u003e      |\n\n**Example**\n\n```js\nlet add3 = curryb(addb, 3)\nadd3(4) // 7\n\ncurryb(mulb, 5)(6) // 30\n```\n\n\u003ca name=\"curry\"\u003e\u003c/a\u003e\n\n## curry(func, ...outer) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `curry` that\nis generalized for any amount\nof arguments\n\n| Param    | Type                  |\n| -------- | --------------------- |\n| func     | \u003ccode\u003efunction\u003c/code\u003e |\n| ...outer | \u003ccode\u003eany\u003c/code\u003e      |\n\n**Example**\n\n```js\ncurry(add, 1, 2, 4)(4, 2, 1) = 1 + 2 + 4 + 4 + 2 + 1 = 14\ncurry(sub, 1, 2, 4)(4, 2, 1) = 1 - 2 - 4 - 4 - 2 - 1 = -12\ncurry(mul, 1, 2, 4)(4, 2, 1) = 1 * 2 * 4 * 4 * 2 * 1 = 64\n```\n\n\u003ca name=\"inc\"\u003e\u003c/a\u003e\n\n## inc(x) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nWithout writting any new functions,\nshow multiple ways to create the `inc`\nfunction\n\n| Param | Type                |\n| ----- | ------------------- |\n| x     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\ninc(5) // 6\ninc(inc(5)) // 7\n```\n\n\u003ca name=\"twiceUnary\"\u003e\u003c/a\u003e\n\n## twiceUnary(binary) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `twiceUnary`\nthat takes a binary function\nand returns a unary function\nthat passes its argument to\nthe binary function twice\n\n| Param  | Type                  |\n| ------ | --------------------- |\n| binary | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet doubl = twiceUnary(addb)\ndoubl(11) // 22\n\nlet square = twiceUnary(mulb)\nsquare(11) // 121\n```\n\n\u003ca name=\"doubl\"\u003e\u003c/a\u003e\n\n## doubl(x) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nUse the function `twiceUnary` to\ncreate the `doubl` function\n\n| Param | Type                |\n| ----- | ------------------- |\n| x     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\ndoubl(11) // 22\n```\n\n\u003ca name=\"square\"\u003e\u003c/a\u003e\n\n## square(x) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n\nUse the function `twiceUnary` to\ncreate the `square` function\n\n| Param | Type                |\n| ----- | ------------------- |\n| x     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nsquare(11) // 121\n```\n\n\u003ca name=\"twice\"\u003e\u003c/a\u003e\n\n## twice(x) ⇒ \u003ccode\u003eany\u003c/code\u003e\n\nWrite a function `twice` that\nis generalized for any amount\nof arguments\n\n| Param | Type                  |\n| ----- | --------------------- |\n| x     | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet doubleSum = twice(add)\ndoubleSum(1, 2, 4) // 1 + 2 + 4 + 1 + 2 + 4 = 14\n```\n\n\u003ca name=\"reverseb\"\u003e\u003c/a\u003e\n\n## reverseb(binary) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `reverseb` that\nreverses the arguments of a\nbinary function\n\n| Param  | Type                  |\n| ------ | --------------------- |\n| binary | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet bus = reverseb(subb)\nbus(3, 2) // -1\n```\n\n\u003ca name=\"reverse\"\u003e\u003c/a\u003e\n\n## reverse(func) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `reverse` that\nis generalized for any amount\nof arguments\n\n| Param | Type                  |\n| ----- | --------------------- |\n| func  | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nreverse(sub)(1, 2, 4) // 4 - 2 - 1 = 1\n```\n\n\u003ca name=\"composeuTwo\"\u003e\u003c/a\u003e\n\n## composeuTwo(unary1, unary2) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `composeuTwo` that\ntakes two unary functions and\nreturns a unary function that\ncalls them both\n\n| Param  | Type                  |\n| ------ | --------------------- |\n| unary1 | \u003ccode\u003efunction\u003c/code\u003e |\n| unary2 | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\ncomposeuTwo(doubl, square)(5) // (5 * 2)^2 = 100\n```\n\n\u003ca name=\"composeu\"\u003e\u003c/a\u003e\n\n## composeu(...funcs) ⇒ \u003ccode\u003eany\u003c/code\u003e\n\nWrite a function `composeu` that\nis generalized for any amount\nof arguments\n\n| Param    | Type                  |\n| -------- | --------------------- |\n| ...funcs | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\ncomposeu(doubl, square, identity, curry(add, 1, 2))(5) // (5 * 2)^2 + 1 + 2 = 103\n```\n\n\u003ca name=\"composeb\"\u003e\u003c/a\u003e\n\n## composeb(binary1, binary2) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `composeb` that\ntakes two binary functions and\nreturns a function that calls\nthem both\n\n| Param   | Type                  |\n| ------- | --------------------- |\n| binary1 | \u003ccode\u003efunction\u003c/code\u003e |\n| binary2 | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\ncomposeb(addb, mulb)(2, 3, 7) // (2 + 3) * 7 = 35\n```\n\n\u003ca name=\"composeTwo\"\u003e\u003c/a\u003e\n\n## composeTwo(func1, func2) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `composeTwo` that\ntakes two functions and returns a\nfunction that calls them both\n\n| Param | Type                  |\n| ----- | --------------------- |\n| func1 | \u003ccode\u003efunction\u003c/code\u003e |\n| func2 | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\ncomposeTwo(add, square)(2, 3, 7, 5) // (2 + 3 + 7 + 5)^2 = 289\n```\n\n\u003ca name=\"compose\"\u003e\u003c/a\u003e\n\n## compose(...funcs) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `compose` that\ntakes any amount of functions\nand returns a function that takes\nany amount of arguments and gives\nthem to the first function, then\nthat result to the second function\nand so on\n\n| Param    | Type                  |\n| -------- | --------------------- |\n| ...funcs | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nconst f = compose(add, doubl, fill, max)\nf(0, 1, 2)\n// add(0, 1, 2) -\u003e 3\n// doubl(3) -\u003e 6\n// fill(6) -\u003e [ 6, 6, 6, 6, 6, 6 ]\n// max(6, 6, 6, 6, 6, 6) -\u003e 6\n```\n\n\u003ca name=\"limitb\"\u003e\u003c/a\u003e\n\n## limitb(binary, lmt) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `limitb`\nthat allows a binary function\nto be called a limited number\nof times\n\n| Param  | Type                  |\n| ------ | --------------------- |\n| binary | \u003ccode\u003efunction\u003c/code\u003e |\n| lmt    | \u003ccode\u003enumber\u003c/code\u003e   |\n\n**Example**\n\n```js\nlet addLmtb = limitb(addb, 1)\naddLmtb(3, 4) // 7\naddLmtb(3, 5) // undefined\n```\n\n\u003ca name=\"limit\"\u003e\u003c/a\u003e\n\n## limit(func, lmt) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `limit` that\nis generalized for any amount\nof arguments\n\n| Param | Type                  |\n| ----- | --------------------- |\n| func  | \u003ccode\u003efunction\u003c/code\u003e |\n| lmt   | \u003ccode\u003enumber\u003c/code\u003e   |\n\n**Example**\n\n```js\nlet addLmt = limit(add, 1)\naddLmt(1, 2, 4) // 7\naddLmt(3, 5, 9, 2) // undefined\n```\n\n\u003ca name=\"genFrom\"\u003e\u003c/a\u003e\n\n## genFrom(x) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `genFrom` that\nproduces a generator that will\nproduces a series of values. Follows the [iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol) for the returned format.\n\n| Param | Type                |\n| ----- | ------------------- |\n| x     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nlet index = genFrom(0)\n\nindex.next().value // 0\nindex.next().value // 1\nindex.next().value // 2\n```\n\n\u003ca name=\"genTo\"\u003e\u003c/a\u003e\n\n## genTo(gen, lmt) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `genTo` that\ntakes a generator and an end\nlimit, and returns a generator\nthat will produce numbers up\nto that limit\n\n| Param | Type                  |\n| ----- | --------------------- |\n| gen   | \u003ccode\u003efunction\u003c/code\u003e |\n| lmt   | \u003ccode\u003enumber\u003c/code\u003e   |\n\n**Example**\n\n```js\nlet index = genTo(genFrom(1), 3)\n\nindex.next().value // 1\nindex.next().value // 2\nindex.next().value // undefined\n```\n\n\u003ca name=\"genFromTo\"\u003e\u003c/a\u003e\n\n## genFromTo(start, end) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `genFromTo` that\nproduces a generator that will\nproduce values in a range\n\n| Param | Type                |\n| ----- | ------------------- |\n| start | \u003ccode\u003enumber\u003c/code\u003e |\n| end   | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nlet index = genFromTo(0, 3)\nindex.next().value // 0\nindex.next().value // 1\nindex.next().value // 2\nindex.next().value // undefined\n```\n\n\u003ca name=\"elementGen\"\u003e\u003c/a\u003e\n\n## elementGen(array, gen) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `elementGen` that\ntakes an array and a generator\nand returns a generator that will\nproduce elements from the array\n\n| Param | Type                  |\n| ----- | --------------------- |\n| array | \u003ccode\u003earray\u003c/code\u003e    |\n| gen   | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet ele = elementGen(['a', 'b', 'c', 'd'], genFromTo(1, 3))\n\nele.next().value // 'b'\nele.next().value // 'c'\nele.next().value // undefined\n```\n\n\u003ca name=\"element\"\u003e\u003c/a\u003e\n\n## element(array, gen) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `element` that is a\nmodified `elementGen` function so that\nthe generator argument is optional.\nIf a generator is not provided, then\neach of the elements of the array\nwill be produced.\n\n| Param | Type                  |\n| ----- | --------------------- |\n| array | \u003ccode\u003earray\u003c/code\u003e    |\n| gen   | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet ele = element(['a', 'b', 'c', 'd'])\n\nele.next().value // 'a'\nele.next().value // 'b'\nele.next().value // 'c'\nele.next().value // 'd'\nele.next().value // undefined\n```\n\n\u003ca name=\"collect\"\u003e\u003c/a\u003e\n\n## collect(gen, array) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `collect` that takes a\ngenerator and an array and produces\na function that will collect the results\nin the array\n\n| Param | Type                  |\n| ----- | --------------------- |\n| gen   | \u003ccode\u003efunction\u003c/code\u003e |\n| array | \u003ccode\u003earray\u003c/code\u003e    |\n\n**Example**\n\n```js\nlet array = []\nlet col = collect(genFromTo(0, 2), array)\n\ncol.next().value // 0\ncol.next().value // 1\ncol.next().value // undefined\narray // [0, 1]\n```\n\n\u003ca name=\"filter\"\u003e\u003c/a\u003e\n\n## filter(gen, predicate) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `filter` that takes a\ngenerator and a predicate and produces\na generator that produces only the\nvalues approved by the predicate\n\n| Param     | Type                  |\n| --------- | --------------------- |\n| gen       | \u003ccode\u003efunction\u003c/code\u003e |\n| predicate | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet third = (val) =\u003e val % 3 === 0\nlet fil = filter(genFromTo(0, 5), third)\n\nfil.next().value // 0\nfil.next().value // 3\nfil.next().value // undefined\n```\n\n\u003ca name=\"filterTail\"\u003e\u003c/a\u003e\n\n## filterTail(gen, predicate) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `filterTail` that uses\ntail-recursion to perform the filtering\n\n| Param     | Type                  |\n| --------- | --------------------- |\n| gen       | \u003ccode\u003efunction\u003c/code\u003e |\n| predicate | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet third = (val) =\u003e val % 3 === 0\nlet fil = filterTail(genFromTo(0, 5), third)\n\nfil.next().value // 0\nfil.next().value // 3\nfil.next().value // undefined\n```\n\n\u003ca name=\"concatTwo\"\u003e\u003c/a\u003e\n\n## concatTwo(gen1, gen2) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `concatTwo` that takes\ntwo generators and produces a generator\nthat combines the sequences\n\n| Param | Type                  |\n| ----- | --------------------- |\n| gen1  | \u003ccode\u003efunction\u003c/code\u003e |\n| gen2  | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet con = concatTwo(genFromTo(0, 3), genFromTo(0, 2))\ncon.next().value // 0\ncon.next().value // 1\ncon.next().value // 2\ncon.next().value // 0\ncon.next().value // 1\ncon.next().value // undefined\n```\n\n\u003ca name=\"concat\"\u003e\u003c/a\u003e\n\n## concat(...gens) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `concat` that\nis generalized for any amount\nof arguments\n\n| Param   | Type                  |\n| ------- | --------------------- |\n| ...gens | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet con = concat(genFromTo(0, 3), genFromTo(0, 2), genFromTo(5, 7))\ncon.next().value // 0\ncon.next().value // 1\ncon.next().value // 2\ncon.next().value // 0\ncon.next().value // 1\ncon.next().value // 5\ncon.next().value // 6\ncon.next().value // undefined\n```\n\n\u003ca name=\"concatTail\"\u003e\u003c/a\u003e\n\n## concatTail(...gens) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `concatTail` that uses\ntail-recursion to perform the concating\n\n| Param   | Type                  |\n| ------- | --------------------- |\n| ...gens | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet con = concatTail(genFromTo(0, 3), genFromTo(0, 2), genFromTo(5, 7))\ncon.next().value // 0\ncon.next().value // 1\ncon.next().value // 2\ncon.next().value // 0\ncon.next().value // 1\ncon.next().value // 5\ncon.next().value // 6\ncon.next().value // undefined\n```\n\n\u003ca name=\"gensymf\"\u003e\u003c/a\u003e\n\n## gensymf(symbol) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `gensymf` that\nmakes a function that generates\nunique symbols\n\n| Param  | Type                |\n| ------ | ------------------- |\n| symbol | \u003ccode\u003estring\u003c/code\u003e |\n\n**Example**\n\n```js\nlet genG = gensymf('G')\nlet genH = gensymf('H')\n\ngenG.next().value // 'G1'\ngenH.next().value // 'H1'\ngenG.next().value // 'G2'\ngenH.next().value // 'H2'\n```\n\n\u003ca name=\"gensymff\"\u003e\u003c/a\u003e\n\n## gensymff(unary, seed) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `gensymff` that\ntakes a unary function and a\nseed and returns a `gensymf`\n\n| Param | Type                  |\n| ----- | --------------------- |\n| unary | \u003ccode\u003efunction\u003c/code\u003e |\n| seed  | \u003ccode\u003enumber\u003c/code\u003e   |\n\n**Example**\n\n```js\nlet gensymf = gensymff(inc, 0)\nlet genG = gensymf('G')\nlet genH = gensymf('H')\n\ngenG.next().value // 'G1'\ngenH.next().value // 'H1'\ngenG.next().value // 'G2'\ngenH.next().value // 'H2'\n```\n\n\u003ca name=\"fibonaccif\"\u003e\u003c/a\u003e\n\n## fibonaccif(first, second) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `fibonaccif` that\nreturns a generator that will\nreturn the next fibonacci number\n\n| Param  | Type                |\n| ------ | ------------------- |\n| first  | \u003ccode\u003enumber\u003c/code\u003e |\n| second | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nlet fib = fibonaccif(0, 1)\nfib.next().value // 0\nfib.next().value // 1\nfib.next().value // 1\nfib.next().value // 2\nfib.next().value // 3\nfib.next().value // 5\nfib.next().value // 8\n```\n\n\u003ca name=\"counter\"\u003e\u003c/a\u003e\n\n## counter(i) ⇒ \u003ccode\u003eobject\u003c/code\u003e\n\nWrite a function `counter` that\nreturns an object containing\ntwo functions that implement\nan up/down counter, hiding\nthe counter\n\n| Param | Type                |\n| ----- | ------------------- |\n| i     | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\nlet obj = counter(10)\nlet { up, down } = obj\n\nup() // 11\ndown() // 10\ndown() // 9\nup() // 10\n```\n\n\u003ca name=\"revocableb\"\u003e\u003c/a\u003e\n\n## revocableb(binary) ⇒ \u003ccode\u003eobject\u003c/code\u003e\n\nWrite a function `revocableb`\nthat takes a binary function, and\nreturns an object containing an\n`invoke` function that can invoke a\nfunction and a `revoke` function\nthat disables the `invoke` function\n\n| Param  | Type                  |\n| ------ | --------------------- |\n| binary | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet rev = revocableb(addb)\n\nrev.invoke(3, 4) // 7\nrev.revoke()\nrev.invoke(5, 7) // undefined\n```\n\n\u003ca name=\"revocable\"\u003e\u003c/a\u003e\n\n## revocable(func) ⇒ \u003ccode\u003eobject\u003c/code\u003e\n\nWrite a function `revocable` that\nis generalized for any amount of\narguments\n\n| Param | Type                  |\n| ----- | --------------------- |\n| func  | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet rev = revocable(add)\n\nrev.invoke(3, 4) // 7\nrev.revoke()\nrev.invoke(5, 7) // undefined\n```\n\n\u003ca name=\"extract\"\u003e\u003c/a\u003e\n\n## extract(array, prop) ⇒ \u003ccode\u003earray\u003c/code\u003e\n\nWrite a function `extract` that\ntakes an array of objects and an\nobject property name and converts\neach object in the array by\nextracting that property\n\n| Param | Type                |\n| ----- | ------------------- |\n| array | \u003ccode\u003earray\u003c/code\u003e  |\n| prop  | \u003ccode\u003estring\u003c/code\u003e |\n\n**Example**\n\n```js\nlet people = [{ name: 'john' }, { name: 'bob' }]\nlet names = extract(people, 'name') // ['john', 'bob']\n```\n\n\u003ca name=\"m\"\u003e\u003c/a\u003e\n\n## m(value, source) ⇒ \u003ccode\u003eobject\u003c/code\u003e\n\nWrite a function `m` that\ntakes a value and an\noptional source string\nand returns them in an\nobject\n\n| Param  | Type             |\n| ------ | ---------------- |\n| value  | \u003ccode\u003eany\u003c/code\u003e |\n| source | \u003ccode\u003eany\u003c/code\u003e |\n\n**Example**\n\n```js\nm(1) // {value:1, source:\"1\"}\n\nm(Math.PI, 'pi') // {value:3.14159..., source:\"pi\"}\n```\n\n\u003ca name=\"addmTwo\"\u003e\u003c/a\u003e\n\n## addmTwo(m1, m2) ⇒ \u003ccode\u003eobject\u003c/code\u003e\n\nWrite a function `addmTwo` that\nadds two `m` objects and\nreturns an `m` object\n\n| Param | Type                  |\n| ----- | --------------------- |\n| m1    | \u003ccode\u003efunction\u003c/code\u003e |\n| m2    | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\naddmTwo(m(3), m(4)) // {value:7, source:\"(3+4)\"}\n\naddmTwo(m(1), m(Math.PI, 'pi')) // {value:4.14159..., source:\"(1+pi)\"}\n```\n\n\u003ca name=\"addm\"\u003e\u003c/a\u003e\n\n## addm(...ms) ⇒ \u003ccode\u003eobject\u003c/code\u003e\n\nWrite a function `addm` that\nis generalized for any amount of\narguments\n\n| Param | Type                  |\n| ----- | --------------------- |\n| ...ms | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\naddm(m(1), m(2), m(4)) // {value:7, source:\"(1+2+4)\"}\n```\n\n\u003ca name=\"liftmbM\"\u003e\u003c/a\u003e\n\n## liftmbM(binary, op) ⇒ \u003ccode\u003eobject\u003c/code\u003e\n\nWrite a function `liftmbM` that\ntakes a binary function and\na string and returns a function\nthat acts on `m` objects\n\n| Param  | Type                  |\n| ------ | --------------------- |\n| binary | \u003ccode\u003efunction\u003c/code\u003e |\n| op     | \u003ccode\u003estring\u003c/code\u003e   |\n\n**Example**\n\n```js\nlet addmb = liftmbM(addb, '+')\n\naddmb(m(3), m(4)) // {value:7, source:\"(3+4)\"}\n\nliftmbM(mul, '*')(m(3), m(4)) // {value:12, source:\"(3*4)\"}\n```\n\n\u003ca name=\"liftmb\"\u003e\u003c/a\u003e\n\n## liftmb(binary, op) ⇒ \u003ccode\u003eobject\u003c/code\u003e\n\nWrite a function `liftmb` that\nis a modified function `liftmbM`\nthat can accept arguments that\nare either numbers or m objects\n\n| Param  | Type                  |\n| ------ | --------------------- |\n| binary | \u003ccode\u003efunction\u003c/code\u003e |\n| op     | \u003ccode\u003estring\u003c/code\u003e   |\n\n**Example**\n\n```js\nlet addmb = liftmb(addb, '+')\n\naddmb(3, 4) // {value:7, source:\"(3+4)\"}\n```\n\n\u003ca name=\"liftm\"\u003e\u003c/a\u003e\n\n## liftm(func, op) ⇒ \u003ccode\u003eobject\u003c/code\u003e\n\nWrite a function `liftm` that\nis generalized for any amount of\narguments\n\n| Param | Type                  |\n| ----- | --------------------- |\n| func  | \u003ccode\u003efunction\u003c/code\u003e |\n| op    | \u003ccode\u003estring\u003c/code\u003e   |\n\n**Example**\n\n```js\nlet addm = liftm(add, '+')\n\naddm(m(3), m(4)) // {value:7, source:\"(3+4)\"}\n\nliftm(mul, '*')(m(3), m(4)) // {value:12, source:\"(3*4)\"}\n```\n\n\u003ca name=\"exp\"\u003e\u003c/a\u003e\n\n## exp(value) ⇒ \u003ccode\u003eany\u003c/code\u003e\n\nWrite a function `exp` that\nevaluates simple array\nexpressions\n\n| Param | Type             |\n| ----- | ---------------- |\n| value | \u003ccode\u003eany\u003c/code\u003e |\n\n**Example**\n\n```js\nlet sae = [mul, 1, 2, 4]\nexp(sae) // 1 * 2 * 4 = 8\nexp(42) // 42\n```\n\n\u003ca name=\"expn\"\u003e\u003c/a\u003e\n\n## expn(value) ⇒ \u003ccode\u003eany\u003c/code\u003e\n\nWrite a function `expn`\nthat is a modified `exp` that\ncan evaluate nested array\nexpressions\n\n| Param | Type             |\n| ----- | ---------------- |\n| value | \u003ccode\u003eany\u003c/code\u003e |\n\n**Example**\n\n```js\nlet nae = [Math.sqrt, [add, [square, 3], [square, 4]]]\n\nexpn(nae) // sqrt(((3*3)+(4*4))) === 5\n```\n\n\u003ca name=\"addg\"\u003e\u003c/a\u003e\n\n## addg(value) ⇒ \u003ccode\u003enumber\u003c/code\u003e \u0026#124; \u003ccode\u003eundefined\u003c/code\u003e\n\nWrite a function `addg` that\nadds from many invocations,\nuntil it sees an empty\ninvocation\n\n| Param | Type                |\n| ----- | ------------------- |\n| value | \u003ccode\u003enumber\u003c/code\u003e |\n\n**Example**\n\n```js\naddg() // undefined\naddg(2)() // 2\naddg(2)(7)() // 9\naddg(3)(0)(4)() // 7\naddg(1)(2)(4)(8)() // 15\n```\n\n\u003ca name=\"liftg\"\u003e\u003c/a\u003e\n\n## liftg(binary) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `liftg` that\nwill take a binary function\nand apply it to many invocations\n\n| Param  | Type                  |\n| ------ | --------------------- |\n| binary | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nliftg(mulb)() // undefined\nliftg(mulb)(3)() // 3\nliftg(mulb)(3)(0)(4)() // 0\nliftg(mulb)(1)(2)(4)(8)() // 64\n```\n\n\u003ca name=\"arrayg\"\u003e\u003c/a\u003e\n\n## arrayg(value) ⇒ \u003ccode\u003earray\u003c/code\u003e\n\nWrite a function `arrayg` that\nwill build an array from many\ninvocations\n\n| Param | Type             |\n| ----- | ---------------- |\n| value | \u003ccode\u003eany\u003c/code\u003e |\n\n**Example**\n\n```js\narrayg() // []\narrayg(3)() // [3]\narrayg(3)(4)(5)() // [3, 4, 5]\n```\n\n\u003ca name=\"continuizeu\"\u003e\u003c/a\u003e\n\n## continuizeu(unary) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `continuizeu`\nthat takes a unary function\nand returns a function that\ntakes a callback and an\nargument\n\n| Param | Type                  |\n| ----- | --------------------- |\n| unary | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet sqrtc = continuizeu(Math.sqrt)\nsqrtc(console.log, 81) // logs '9'\n```\n\n\u003ca name=\"continuize\"\u003e\u003c/a\u003e\n\n## continuize(func) ⇒ \u003ccode\u003efunction\u003c/code\u003e\n\nWrite a function `continuize`\nthat takes a function and\nreturns a function that\ntakes a callback and arguments\n\n| Param | Type                  |\n| ----- | --------------------- |\n| func  | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nlet mullc = continuize(mul)\nmullc(console.log, 81, 4, 2) // logs '648'\n```\n\n\u003ca name=\"vector\"\u003e\u003c/a\u003e\n\n## vector()\n\nMake an array wrapper object\nwith methods `get`, `store`,\nand `append`, such that an\nattacker cannot get access\nto the private array\n\n**Example**\n\n```js\nlet v = vector()\nv.append(7)\nv.store(1, 8)\nv.get(0) // 7\nv.get(1) // 8\n```\n\n\u003ca name=\"exploitVector\"\u003e\u003c/a\u003e\n\n## exploitVector()\n\nLet's assume your `vector`\nimplementation looks like\nsomething like this:\n\n```js\nlet vector = () =\u003e {\n  let array = []\n  return {\n    append: (v) =\u003e array.push(v),\n    get: (i) =\u003e array[i],\n    store: (i, v) =\u003e array[i] = v\n  }\n}\n```\n\nCan you spot any security concerns with\nthis approach? Mainly, can we get access\nto the `array` outside of `vector`?\nNote*: the issue has nothing to do with\nprototypes and we can assume that global\nprototypes cannot be altered.\nHint*: Think about using `this` in a\nmethod invocation. Can we override a\nmethod of `vector`?\n\n**Example**\n\n```js\nlet v = vector()\nv.append(1)\nv.append(2)\nlet internalData = exploitVector(v) // [1, 2]\n```\n\n\u003ca name=\"vectorSafe\"\u003e\u003c/a\u003e\n\n## vectorSafe()\n\nHow would you rewrite `vector` to deal\nwith the issue from above?\n\n**Example**\n\n```js\nlet v = vectorSafe()\nv.append(1)\nv.append(2)\nlet internalData = exploitVector(v) // undefined\n```\n\n\u003ca name=\"pubsub\"\u003e\u003c/a\u003e\n\n## pubsub()\n\nMake a function `pubsub` that\nmakes a publish/subscribe object.\nIt will reliably deliver all\npublications to all subscribers\nin the right order.\n\n**Example**\n\n```js\nlet ps = pubsub()\nps.subscribe(console.log)\nps.publish('It works!') // logs 'It works!'\n```\n\n\u003ca name=\"mapRecurse\"\u003e\u003c/a\u003e\n\n## mapRecurse(array, callback) ⇒ \u003ccode\u003earray\u003c/code\u003e\n\nMake a function `mapRecurse` that\nperforms a transformation for each\nelement of a given array, recursively\n\n| Param    | Type                  |\n| -------- | --------------------- |\n| array    | \u003ccode\u003earray\u003c/code\u003e    |\n| callback | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nmapRecurse([1, 2, 3, 4], (x) =\u003e x * 2) // [ 2, 4, 6, 8 ]\n```\n\n\u003ca name=\"filterRecurse\"\u003e\u003c/a\u003e\n\n## filterRecurse(array, predicate) ⇒ \u003ccode\u003earray\u003c/code\u003e\n\nMake a function `filterRecurse` that\ntakes in an array and a predicate\nfunction and returns a new array by\nfiltering out all items using the\npredicate, recursively.\n\n| Param     | Type                  |\n| --------- | --------------------- |\n| array     | \u003ccode\u003earray\u003c/code\u003e    |\n| predicate | \u003ccode\u003efunction\u003c/code\u003e |\n\n**Example**\n\n```js\nfilterRecurse([1, 2, 3, 4], (x) =\u003e x % 2 === 0) // [ 2, 4 ]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero-to-mastery%2Fjs_fun_practice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzero-to-mastery%2Fjs_fun_practice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero-to-mastery%2Fjs_fun_practice/lists"}