Skip to main content
7 events
when toggle format what by license comment
Mar 20, 2019 at 9:21 comment added Renzo @mwal, yes, I love the barki's cartoon too. For the best version: for readability I am oriented towards the loop solution, but the last one is surely a good second for me. After so many years of programming, I tend to see recursion as just another tool to use when needed: the elegance for me is mostly a mix of readability, conciseness and efficiency.
Mar 19, 2019 at 16:01 comment added mwal Your final example is something I now realise I'd wanted to express but didn't know how get an incrementing value into the function passed to the map function. Mutable state 'to the rescue' (?). (is this barski's "lisp alien" rearing its hand-trunk for us? :)) In sum, maybe that final three liner wins hands down for compactness, of all the versions we've considered. What do you think? So to conclude: Q. Are there any drawbacks of coding in this way? (i do yearn for more recursion on aesthetic grounds, but the mapcar with state version looks like it could be the winner :))
Mar 19, 2019 at 13:55 comment added Renzo I confess at first using 1+ and 1- was not always immediate for me, but after some time I was quite used to them. Maybe inc and dec were not used since they look too similar to incf and decf, that have a very different meaning, or maybe it was considered funny to prove that in CommonLisp symbols can have very peculiar names! Modern compiler optimization techniques of course make useless such specific operators, however, and I think they are still used just because of habit.
Mar 19, 2019 at 13:46 history edited Renzo CC BY-SA 4.0
added 10 characters in body
Mar 19, 2019 at 13:13 comment added mwal Thank you @Renzo! May I ask a stylistic question on the 1+ function: I do want to use it and probably will, but first impression is it seems syntactically egregious, appearing to imply infix notation. Does one just get used to the functions 1+ & 1-, or is there some mitigating reason for them to be named that way which does make them aesthetically 'ok'? e.g. obviously 'inc' & 'dec' are just one more character, and don't 'look like a typo', which to me those do in a way, at least right now!
Mar 19, 2019 at 12:21 history edited Renzo CC BY-SA 4.0
added 429 characters in body
Mar 19, 2019 at 12:14 history answered Renzo CC BY-SA 4.0