I wrote a function to get everything but the last element of a List from std-lib:
allButLast : ∀ {a} {A : Set a} → List A → List A allButLast [] = l