I got the following question at a test:
Write a function
f
with the following typea -> b -> (a -> b)
.a
andb
should not be bound in any sense, the shorter the code, the better.
I came up with f a b = \x -> snd ([a,x],b)
. Can you find something tinier?
Currently the winner is: f _=(.f).const
f _ b _ = b
, but, given the solution in the question, I suspect a more general type is not allowed. \$\endgroup\$f = id
? \$\endgroup\$f = f
is a solution, so I guess the conditions on the type are very important! \$\endgroup\$const
bypure
, which is one character less. \$\endgroup\$