/* Author : Freeman lo last --> finds the last item in a list and returns that item nexttolast --> finds the next to last item in a list and returns that item lasttworev --> finds the last two items in a list and reverse it and returns those last two items as a list revlasttwo --> finds the reverse of the last two item in a list and returns the entire list with the last two reversed */ %Part 1, Answer last([A|[]], A). last([Head|Tail],Answer):- last(Tail, Answer ). %Part 2, Answer nexttolast([A,B], A). nexttolast([Head|Tail], Answer) :- nexttolast(Tail,Answer). %Part 3, Answer lasttworev([A,B], [B,A]). lasttworev([A|Z], Answer ) :- lasttworev(Z,Answer). %Part 4, Answer revlasttwo([A,B],[B,A]). revlasttwo([A|Z1], [A|Z2]) :- revlasttwo(Z1,Z2).