Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And if you want Python-style iterators, that's easy too:

http://blog.rongarret.info/2008/02/joy-of-iterators.html



So, that thing I mentioned yesterday that I wrote 35 years ago? It might interest you:

  https://github.com/slburson/misc-extensions
Look in src/gmap.lisp.

I admit it wouldn't work that well for 'n-at-a-time', but here's a closely related example:

  (defun alist-to-plist (alist)
    (gmap :plist nil (:alist alist)))
There are some idiosyncrasies here: 'nil' is shorthand for the identity function (in this case, the two-argument, two-value identity function), and the use of keyword symbols is weird and potentially problematic, though I've never run into a problem with it in practice.

This is the map-reduce model of iteration -- obviously not with support for distributed computation, but nonetheless useful for programming in the small. And far more elegant, to my eyes, than that LOOP monstrosity :-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: