7 kyu

Currying functions: multiply all elements in an array

12,546 of 16,013limeyb7

Description:

To complete this Kata you need to make a function multiplyAll/multiply_all which takes an array of integers as an argument. This function must return another function, which takes a single integer as an argument and returns a new array.

The returned array should consist of each of the elements from the first array multiplied by the integer.

Example:

multiplyAll([1, 2, 3])(2) = [2, 4, 6];
multiply_all([1, 2, 3])(2); // => [2, 4, 6]
multiply_all([1, 2, 3])(2); // => [2, 4, 6]
multiplyAll(Seq(1, 2, 3))(2); // => Seq(2, 4, 6)
(multiply_all [1; 2; 3]) 2 (* [2; 4; 6] *)

You must not mutate the original array.

Here's a nice Youtube video about currying, which might help you if this is new to you.

Functional Programming
Fundamentals

More By Author:

Check out these other kata created by limeyb7

Stats:

CreatedJan 1, 2017
PublishedJan 1, 2017
Warriors Trained24252
Total Skips867
Total Code Submissions35706
Total Times Completed16013
JavaScript Completions12546
PHP Completions329
C# Completions309
Elixir Completions158
Python Completions2361
Scala Completions142
Java Completions380
OCaml Completions33
Total Stars203
% of votes with a positive feedback rating93% of 1512
Total "Very Satisfied" Votes1332
Total "Somewhat Satisfied" Votes145
Total "Not Satisfied" Votes35
Total Rank Assessments12
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • limeyb7 Avatar
  • joh_pot Avatar
  • bwignall Avatar
  • donaldsebleung Avatar
  • Chrono79 Avatar
  • kazk Avatar
  • docgunthrop Avatar
  • JohanWiltink Avatar
  • Madjosz Avatar
  • Souzooka Avatar
  • flaco Avatar
  • monadius Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • user8436785 Avatar
  • KayleighWasTaken Avatar
  • saudiGuy Avatar
Ad