display
is useful for seeing the intermediate results of a function as it runs. It's tiresome to clutter our programs with calls to display
, though. A way to log the inputs and outputs of a function would be nice.
Define the function debug1
, which takes a function argument f and returns a function that, when called, writes its input and output to the console, and returns the same thing f would have when called. In other words, the type of debug1
is (x -> y) -> (x -> y)
.