Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jfarmer/exercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exercises

Contents

Regular Expressions

See README in regex

CLI

See README in cli.

Grep

See README in grep

Binary Trees

See README in binary-trees.

Graphs

See README in graphs.

Recursion

See README in recursion.

Using the following template, implement the functions in the relevant file:

function template(list) {
  if (isEmpty(list)) {
    return _____;
  }

  let [first, rest] = unprepend(list);

  return _____;
}

Use this same template to implement foldl and foldr. These are higher-level functions called fold (fold left and fold right, respectively). In JavaScript, reduce is a left fold and reduceRight is a right fold.

Re-implement the functions as a single call to foldl and as a single call to foldr. Some functions are easier to implement using one pattern rather than the other. Why?

Every function can be modified to work with arrays, too. You will find it easier to use left fold with append and unappend, though.

See A tutorial on the universality and expressiveness of fold.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published