So I’ve been working on the first of the PSP exercises. The requirement is to write code that calculates the average and standard deviation of a linked list.
My first attempt hasn’t ended in failure, so much as the realisation that I took the wrong approach. I’ve marked this down as a design defect in my error log.
The emphasis really ought to be on the standard deviation and not on the data structure. I’m writing in Lua, a language which among other things includes a flexible standard data structure called ‘tables’, which can at various times behave like arrays, hashes, stacks, queues and so on.
My next revision of the code will focus on using tables as-is, rather than bodging up a linked-list structure composed of tables with two elements. I expect it will probably be much easier to write, too, due to Lua’s support for easy iteration over table structures.