help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cl-loop and collect (was: Re: A more specific/targeted version of macroe


From: Emanuel Berg
Subject: cl-loop and collect (was: Re: A more specific/targeted version of macroexpand-all?)
Date: Thu, 09 Jun 2022 03:40:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Okamsn wrote:

> (cl-loop for i being the symbols
>          when (eq 'macro (car-safe (symbol-function i)))
>          collect i)

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/negative-subtraction.el

(require 'cl-lib)

(defun number-to-list (n)
  (cl-loop
    for d across (prin1-to-string n)
    collect (cl-digit-char-p d) ))
;; (number-to-list 1234) ; (1 2 3 4)

(defun negative-subtract (a b)
  (let*((a-nums (number-to-list a))
        (b-nums (number-to-list b)) )
    (cl-loop
      for i in a-nums
      for j in b-nums
      collect (- i j) )))
;; (negative-subtract 8888 7777) ; (1 1 1 1)

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]