Functional programming in Bash with linked lists and higher-order functions