Advertisement
mark-naylor-1701

Haskell style head/tail functions in elisp

Sep 28th, 2023 (edited)
2,427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.30 KB | None | 0 0
  1. (defun square (n) (* n n))
  2.  
  3. (defun head-tail (&optional head &rest tail)
  4.   (when head
  5.     (insert (format "%d\n" (square head)))
  6.     (apply #'head-tail tail)))
  7.  
  8.  
  9. (defun head-tail (&optional head &rest tail)
  10.   (when head
  11.     (cons (square head) (apply #'head-tail tail))))
  12.  
  13.  
  14. (head-tail 1 2 3 4 5)
  15.  
Tags: elisp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement