Skip to content

Instantly share code, notes, and snippets.

@shelling
Created April 12, 2011 05:48
Show Gist options
  • Save shelling/915016 to your computer and use it in GitHub Desktop.
Save shelling/915016 to your computer and use it in GitHub Desktop.
foreach in elisp
#!/usr/bin/env emacs --script
(require 'cl)
(defun foreach (alist func)
(while alist
(progn
(funcall func (car alist))
(setq alist (cdr alist)))
))
(setq foo '("hello" "world"))
(foreach foo
(lambda (x) (message x)))
(foreach '(1 2 3)
(lambda (x) (message "%d" (+ 10 x))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment