My solution uses two rules. Scroll down to see it.
first_last(L,First) :- append([First],_,L).
first_last(L,Last) :- append(_,[Last],L).