my first run at this problem actually landed me with something like that, but it lacked the grace of a good hack.
deciding that a concise solution was not to be found with this problem, i chose to try and compensate with legibility.
here's that awkward first solution of mine using the temp val: