Questions tagged [mapping]

34 questions
17
votes
4 answers

Is there an idiomatic way of reading each line in a buffer to process it line by line?

In Python I'd do the following to process a file line by line: with open(infile) as f: for line in f: process(line) Trying to look up how to do the same in elisp (with buffers instead of files), I found no obvious way. (What I want to…
The Unfun Cat
  • 2,413
  • 17
  • 32
9
votes
3 answers

How to apply mapcar to a function with multiple arguments

I have packages variables that have list of github users and package names. (defvar packages '('("auto-complete" . "auto-complete") ("defunkt" . "markdown-mode"))) I want to git clone if the file is not exist yet. (defun…
ironsand
  • 423
  • 3
  • 14
6
votes
2 answers

Emacs - Understand elisp syntax (mapcar '1+ '(2 4 6))

I saw this example code: (mapcar '1+ '(2 4 6)) ⇒ (3 5 7) But I do not understand '1+ here. it will apply a function to a list but this style obviously not like a function. If means add, the function should be +, what does '1+ mean?
beetlej
  • 1,098
  • 1
  • 7
  • 20
1
vote
1 answer

How to include an index in a list generated by mapcar?

This statements generates a list of (list filename buf), How could this be written to include an index as well? eg: (list index filename buf) where the index would be a counter, starting at zero, increment 1 for each item. (mapcar (lambda (buf)…
ideasman42
  • 8,786
  • 1
  • 32
  • 114