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! )
Similar Kata:
Stats:
Created | Mar 9, 2021 |
Published | Mar 9, 2021 |
Warriors Trained | 115 |
Total Skips | 5 |
Total Code Submissions | 171 |
Total Times Completed | 39 |
Haskell Completions | 39 |
Total Stars | 6 |
% of votes with a positive feedback rating | 81% of 18 |
Total "Very Satisfied" Votes | 13 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 4 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |