I defined allButLast this way:
allButLast
allButLast : ∀ {a} {A : Set a} → List A → List A allButLast l.[] = l.[] allButLast list = l.reverse (tail\' (l.rev