On Fri, Oct 24, 2008 at 05:54:10PM +0200, Alexander Burger wrote:
> > Do you have anything on mind?
> Unfortunately not. I just had the feeling there must be other ways ;-)
Perhaps I was too much in a hurry yesterday ...
There is a kind of middle way between our two solutions:
(let @S '((I . 0))
(def 'count (curry (@S) () (job '@S (inc 'I))))
(def 'reset (curry (@S) () (job '@S (zero I)))) )
This is not shorter than your initial solution, but perhaps a little bit
more clear by letting 'curry' do the job of building the function.
BTW, all three solutions have in common that they depend on a shared
data structure (a cell (I . 0) or (0)). If the 'let' is going to be used
within some other function (instead of the top level here), it should
(let @S (list (cons 'I 0))
(let I (cons 0)
to use a locally encapsulated cell.
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]