7 kyu

functions $$$ of $$ multiple $ arguments

Description:

Data.Function

($) :: forall r a (b :: TYPE r). (a -> b) -> a -> b  | infixr 0 |

Application operator. This operator is redundant, since ordinary application (f x) means the same as (f $ x). However, $ has low, right-associative binding precedence, so it sometimes allows parentheses to be omitted; for example:

f $ g $ h x  =  f (g (h x))

It is also useful in higher-order situations, such as map ($ 0) xs, or zipWith ($) fs xs.


Task

($) is great if your function takes one argument. What's missing is ($$) in map $$ fn $ xs, which can be very useful if fn and / or xs are complicated compound expressions.

Define ($$). Also define ($$$), for functions that take three arguments ( hello, zipWith, foldr and liftA2 ! ).

Forms like f $$ x, without more arguments, f $$ g $$ y, and such with ($$$), should also work ( these may be encountered during incomplete refactoring ).

Examples

map $$ f $ xs == map f xs
map $$ f . g $ xs ++ ys == map (f . g) (xs ++ ys)

zipWith $$$ f $$ xs $ ys == zipWith f xs ys
zipWith $$$ f . g $$ xs ++ ys $ as ++ bs == zipWith (f . g) (xs ++ ys) (as ++ bs)

Testing

Expect unfriendly, unhelpful compilation errors rather than friendly, helpful test failures for incorrect solutions. We apologise for the inconvenience.
The Submit tests are exactly the same as the Example tests.
There are no random tests. I could honestly not imagine useful ones. This may be the exception that confirms the rule. ( Or it may not be, and I very much look forward to any suggestions! )

Algorithms

Similar Kata:

Stats:

CreatedMar 9, 2021
PublishedMar 9, 2021
Warriors Trained115
Total Skips5
Total Code Submissions171
Total Times Completed39
Haskell Completions39
Total Stars6
% of votes with a positive feedback rating81% of 18
Total "Very Satisfied" Votes13
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes2
Total Rank Assessments4
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • JohanWiltink Avatar
  • monadius Avatar
Ad