[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Output an alist from a function
From: |
tomas |
Subject: |
Re: Output an alist from a function |
Date: |
Tue, 24 Sep 2024 17:04:20 +0200 |
On Mon, Sep 23, 2024 at 09:42:38PM +0000, Heime wrote:
>
> I have an alist composed of keys and associated directory paths, and want
> to output an alist made of the same keys with values being a validation flag.
> Perhaps the problem is the call to mapcar. In the case of the hash table I
> have
> to call output-table after the maphash.
>
> (defun dirpath-validation (input-table-or-alist)
> "Test validity of directory path for each key."
>
> (cond
>
> ((hash-table-p input-table-or-alist)
>
> ;; Make hash-table for output
> (let ( (output-table (make-hash-table :test 'equal)) )
> (maphash (lambda (key dirpath)
> (puthash key (not (file-directory-p dirpath))
> output-table))
> input-table-or-alist)
> output-table))
>
> (t
> (mapcar (lambda (entry)
> (let ( (key (car entry))
> (dirpath (cdr entry)) )
> (cons key (not (file-directory-p dirpath)))) )
> input-table-or-alist)) ))
I've some difficulties figuring out what your question is.
Is it that you want to write a function which "does the same"
as output-table does, but for alist?
Then we don't know what output-table does, so we can only guess.
Assuming it writes its content into a buffer, each entry on one
line, key and value separated by space, then this might do as a
rough prototype:
(insert
(mapc
(lambda (k v) (format "%s %s\n) k v)
input-table-or-alist))
Cheers
--
t
signature.asc
Description: PGP signature
- Output an alist from a function, Heime, 2024/09/23
- Re: Output an alist from a function,
tomas <=
- Re: Output an alist from a function, Heime, 2024/09/24
- Re: Output an alist from a function, tomas, 2024/09/25
- Output an alist from a function, Heime, 2024/09/25
- Re: Output an alist from a function, tomas, 2024/09/26
- Re: Output an alist from a function, Heime, 2024/09/26
- Re: Output an alist from a function, tomas, 2024/09/26
- Re: Output an alist from a function, Heime, 2024/09/26
Re: Output an alist from a function, Stephen Berman, 2024/09/24