From Newsgroup: gnu.emacs.help
"H.Singh" <
hashish0singh@gmail.com> writes:
Friends,
I am trying to add two sequences like this:
[1 2 3 4 5 6 7 8]
[2 1 2 1 2 1 2 1]
and I can accomplish this using this one liner code in elisp.
(mapcar* (lambda (x y) (+ x y)) ; element-wise addition
[1 2 3 4 5 6 7 8]
[2 1 2 1 2 1 2 1]
)
(seq-mapn #'+ '(2 4 5) '(1 2 3))
(seq-reduce #'+ '(1 2 3 4 5) 0)
(seq-intersection [2 3 4 5] [1 3 5 6 7])
rcA (3 5)
This is right out of the elisp manual. You can view the section on
sequences.
M-x (info "(elisp)Sequence Functions")
Readability is more important than elegance. I do not want write once code that is not easily remembered.
Check out the tutorial on elisp. C-h i RET M elisp
The tutorial is built into emacs via info pages. Check the help menu.
Help > More Manuals > Elisp...
H Singh
--- Synchronet 3.21d-Linux NewsLink 1.2