Functional programming for appending, merging and sorting linked lists.