[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help with recursive destructive function
From: |
Michael Heerdegen |
Subject: |
Re: Help with recursive destructive function |
Date: |
Sat, 05 May 2018 03:37:00 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
> You want to do something more like
>
> (let ((xs thing))
> (while (consp xs)
> (let ((x (car xs)))
> (cond
> ((stringp x) (setf (car xs) (upcase x)))
> ((listp x) (walk x)))
> (setq xs (cdr xs)))))
`cl-loop' can do this out of the box (not recursively, though):
‘for VAR being the elements of-ref SEQUENCE’
This clause iterates over a sequence, with VAR a ‘setf’-able
reference onto the elements; see ‘in-ref’ above.
Exactly what he wants.
I'm not sure, however, if it's a good idea to use a recursive function
to do that. Recursing on cdrs can soon hit Emacs limits for very long
lists (and Eric, remember all the nested quotes you will need to
traverse ;-) ). I guess I would use an iterator: the definition would
still looks recursive, but the execution isn't problematic any more if
done right.
Michael.
- Help with recursive destructive function, Eric Abrahamsen, 2018/05/04
- Re: Help with recursive destructive function, Stefan Monnier, 2018/05/04
- Re: Help with recursive destructive function,
Michael Heerdegen <=
- Re: Help with recursive destructive function, Eric Abrahamsen, 2018/05/06
- Re: Help with recursive destructive function, Michael Heerdegen, 2018/05/06
- Re: Help with recursive destructive function, Eric Abrahamsen, 2018/05/06
- Re: Help with recursive destructive function, Clément Pit-Claudel, 2018/05/07
- Re: Help with recursive destructive function, Michael Heerdegen, 2018/05/07
- Re: Help with recursive destructive function, Stefan Monnier, 2018/05/07