all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Validates an input hash table to produce another  hash table
@ 2024-09-23 12:53 Heime
  2024-09-23 13:14 ` Yuri Khan
  0 siblings, 1 reply; 3+ messages in thread
From: Heime @ 2024-09-23 12:53 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I am writing that validates an input hash table to produce another 
hash table with the result (replacing the directory path with the 
validation value).

(defun path-validation (input-table)

  (cond

      ((hash-table-p input-table)

      ;; 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)
        output-table))

      (t
         (mapcar (lambda (entry)
              (let ( (key  (car entry))
                     (dirpath  (cdr entry)) )
                (cons key (not (file-directory-p dirpath)))) )
            input-table)) ))


(defun print-hash-table (hash-table &optional bfrn)
  "Print HASH-TABLE to the buffer BFRN."

  (let* ( (bfname (or bfrn "Hash Table"))
          (dbuffer (get-buffer-create (concat "Project " bfname))) )

    (with-current-buffer dbuffer
      (maphash (lambda (key value)
                 (let* ( (start (point)) )
                   (insert (format "%-8s" key))
                   (insert (format "\n    %s\n" value))))
               hash-table))))


(let ( (input-table (make-hash-table :test 'equal)) )

  (puthash "home-dir" "/home/user" input-table)
  (puthash "docs-dir" "/home/user/Documents" input-table)
  (puthash "fake-dir" "/non/existing/path" input-table)

  (print-hash-table input-table "Input Table")

  (let ( validation-table (path-validation input-table) )
    (print-hash-table validation-table "Output Table")  ; <== Problem Here
    (message "Done"))

  (message "Done"))




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Validates an input hash table to produce another hash table
  2024-09-23 12:53 Validates an input hash table to produce another hash table Heime
@ 2024-09-23 13:14 ` Yuri Khan
  2024-09-23 19:11   ` Heime
  0 siblings, 1 reply; 3+ messages in thread
From: Yuri Khan @ 2024-09-23 13:14 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Mon, 23 Sept 2024 at 19:54, Heime <heimeborgia@protonmail.com> wrote:

> (let ( (input-table (make-hash-table :test 'equal)) )

>   (let ( validation-table (path-validation input-table) )

Parentheses.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Validates an input hash table to produce another hash table
  2024-09-23 13:14 ` Yuri Khan
@ 2024-09-23 19:11   ` Heime
  0 siblings, 0 replies; 3+ messages in thread
From: Heime @ 2024-09-23 19:11 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

On Tuesday, September 24th, 2024 at 1:14 AM, Yuri Khan <yuri.v.khan@gmail.com> wrote:

> On Mon, 23 Sept 2024 at 19:54, Heime heimeborgia@protonmail.com wrote:
> 
> > (let ( (input-table (make-hash-table :test 'equal)) )
> 
> > (let ( validation-table (path-validation input-table) )
> 
> 
> Parentheses.

Thank you for pointing that out. As you correctly noted, the problem was indeed 
a very simple problem with parentheses which caused the error.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-23 19:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-23 12:53 Validates an input hash table to produce another hash table Heime
2024-09-23 13:14 ` Yuri Khan
2024-09-23 19:11   ` Heime

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.