Clearly in earlier (unpublished) attempts at using the
case construct in Erlang, I had been making some very n00bish mistakes. Today with a set of code that worked, and could be modified step-wise, I find that when used properly, it does make things terser -- fewer intermediate variables, and without the
true branch meaning "
false" -- and then lets me pattern match on expressions that are functions of arguments, rather than only the arguments themselves.
The use of
if for crossing_time and display gives a natural
if/else if cascade (as the most "traditional" analogue for what the Erlang
if does). Most of the time, using
case has made the code terser (removing the need for most temporaries in simple binary choices, if nothing else -- here best_step is an exception, where the temporary looks to be a necessity); for update, it was about neutral. Maybe there is a trick I am missing, but anything going through a binary looks like it would make crossing_time and display more cumbersome, rather than less.