Skip to content

azerum/recursed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Solutions to esoteric task I've once given to my friend who wanted to learn more about recusion and functional programming. The task is to implement all functions bellow (hopefully it's clear what they should do from their names):

  • min(array)
  • max(array)
  • sum(array)
  • product(array)
  • average(array)
  • removeAt(array, index)
  • insertAfter(array, index, value)
  • concat(arrayA, arrayB)
  • indexOf(array, value)
  • reverse(array)
  • sort(array)

The trick is that:

  • All functions must be written as lambdas without code blocks: () => . Effectively, all the code you write will be just expressions, without statements

  • Global variables, mutations and side effects are not allowed

  • In all functions except head, tail and prepend, the following syntaxes are prohibited: indexer access (array[i]), object spread ({ ...obj }) array spread ([...array])

About

Recursion tasks

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published