a Clojure function I wrote because I often want to do something different to the final element of a lazy sequence
(defn
map-differentiating-last
[f last-f s]
(let
[sigil
(Object.)]
(->>
(concat
s
[sigil])
(partition 2 1)
(map
(fn
[[a b]]
(if
(identical? sigil b)
(last-f a)
(f a)))))))