From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime Newsgroups: gmane.emacs.help Subject: Re: Printing a hash table Date: Mon, 23 Sep 2024 12:10:23 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23453"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: tomas@tuxteam.de Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 23 14:11:26 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sshuX-0005tj-UW for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 23 Sep 2024 14:11:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sshtn-0001bB-Mb; Mon, 23 Sep 2024 08:10:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sshth-0001a0-Sn for help-gnu-emacs@gnu.org; Mon, 23 Sep 2024 08:10:34 -0400 Original-Received: from mail-40141.protonmail.ch ([185.70.40.141]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sshtf-0002Ev-AY for help-gnu-emacs@gnu.org; Mon, 23 Sep 2024 08:10:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1727093427; x=1727352627; bh=ypucsEyfbrLAwDija+QPe9KPODfDJGoB4mES8X7ru7Y=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=ZDq62yozTY//RHs4QrAMiEMRk4WmbSUoAX+5h1dPGGJpbdVJPl5GmkiDGhuX4sWwY MdZAhMQrSVBT9yMxay3KS3WHkwHzK4rDqJ82UDiBm71xSpgfvZDSYf/KfBNoX6kp3f ODG/bGivqPQQ35Ui5QYRIYy0KFbD38seS7SpRKb3UaOYxm/LjNv7RCRc5eba0bfcBM 8+cEULDWhFrYa80Pr+XKr3QgM13A+J7PKDmWqkvLy2K9LSwcM+Nl1DEXUoqF6/ZZYV DVxMtHJL9eBRWiLgnHFyYI9b0jnnUeHC4PKT11E9hJNr1zOcuZNFqLI84U8okNBdPa 8dZxiACWMPpZA== In-Reply-To: Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 77f3b350b499b12f0f90bf1f6aa989ccff8444cd Received-SPF: pass client-ip=185.70.40.141; envelope-from=heimeborgia@protonmail.com; helo=mail-40141.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148042 Archived-At: Sent with Proton Mail secure email. On Monday, September 23rd, 2024 at 6:32 PM, tomas@tuxteam.de wrote: > On Mon, Sep 23, 2024 at 02:30:31AM +0000, Heime wrote: >=20 > > Is this the way to fill a hash table and print the values. > >=20 > > (defvar marshal-fpln (make-hash-table :test 'equal) > > "Hash table storing paths for different marshal components.") > >=20 > > (defun marshal-insert () > >=20 > > (puthash "MRSHL" marshal-waypt marshal-fpln) > > (puthash "NAPLN" (concat marshal-waypt "/poleon") marshal-fpln) > > (puthash "FLKTR" (concat rellana-waypt "/alkotr") marshal-fpln) > > (puthash "GLXKS" (concat rellana-waypt "/xiakos") marshal-fpln) > > (puthash "ARKTK" (concat rellana-waypt "/ritika") marshal-fpln) ) > >=20 > > (defun torium-hash-table (hash-table &optional bfrn) > > "Print HASH-TABLE to the buffer BFRN." > >=20 > > (let* ( (bfname (or bfrn "Torium Hash Table")) > > (dbuffer (get-buffer-create (concat "=F0=92=86=B3 " bfname))) ) > >=20 > > (with-current-buffer dbuffer > > (maphash (lambda (key value) > > (let* ( (start (point)) ) > > (insert (format " =E2=94=81 %-8s" key)) > > (insert (format "\n %s\n" value)))) > > hash-table)))) > >=20 > > I am getting the following error and cannot figure out how I can get ou= t of it. > >=20 > > Debugger entered--Lisp error: (wrong-type-argument hash-table-p (("MRSH= L") ("NAPLN") ("FLKTR") ("GLXKS") ("ARKTK" . t))) > > maphash((closure (t) (key value) (let* ((start (point))) (insert (forma= t " =E2=94=81 %-8s" key)) (add-text-properties start (point) '(face (:foreg= round "green"))) (insert (format "\n %s\n" value)))) (("MRSHL") ("NAPLN") (= "FLKTR") ("GLXKS") ("ARKTK" . t))) >=20 >=20 > [rest of stack trace removed] >=20 > Please, do some homework. This helps people help you (this is actually > why I, at some point, stopped trying). Moreover, your (for the rest of > us) inscrutable variable names aren't helping. >=20 > Asking for programming help involves trying to help your helpers to > understand your problem. I feel that you aren't doing this (for whatever > reason). This will impair the quality of answers you get. >=20 > And third, you really, really should try to gain some more understanding > and practice with small Lisp code snippets. I have the impression that > you only half-grasped very basic concepts and run into the same kind of > problems time and again. Every bit you invest in the basics will pay back > hundredfold (and will motivate your potential helpers). >=20 > OK, that said, let's try to decode the two first lines of the error messa= ge > (I reformat them to make them fit a civilised window width and to highlig= ht > their structure). Notes inline, prefixed with #. They are numbered to ref > to them further down. >=20 > > Debugger entered--Lisp error: >=20 > # (1) The lisp run time has signalled an error, and the debugger is repor= ting that: >=20 > > (wrong-type-argument hash-table-p >=20 > # (2) Some function expects an argument satisfying the predicate hash-tab= le-p and > # has got instead... >=20 > > (("MRSHL") ("NAPLN") ("FLKTR") ("GLXKS") ("ARKTK" . t))) >=20 > # (3) ...something which looks a lot like an alist (the four first entrie= s are associated > # to nil, that's why they possibly look like singletons) >=20 > Ad (2): Which function could that be? Look again at your code. > The only one I see is that maphash, restated (and abbreviated) > here: >=20 > > (maphash (lambda (key value) ...) hash-table) >=20 >=20 > It gets two args (which corresponds to the doc). The first one > is the function to be iterated. The second is hash-table, which, > according to the doc, is expected to be a hash table. >=20 > Now where is that one coming from? It is passed as a param to your > torium-hash-table: we don't see how you are calling that one. I > conclude that (unless I've missed something) the error cause is > outside the code snippet you show us. >=20 > Cheers > -- > t You are right. Have not worked with hash-tables before. Still, when I=20 post some code I shall change the names to be easier to follow through.