{"action":"created","issue":{"url":"https://api.github.com/repos/caiorss/Emacs-Elisp-Programming/issues/12","labels_url":"https://api.github.com/repos/caiorss/Emacs-Elisp-Programming/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/caiorss/Emacs-Elisp-Programming/issues/12/comments","events_url":"https://api.github.com/repos/caiorss/Emacs-Elisp-Programming/issues/12/events","html_url":"https://github.com/caiorss/Emacs-Elisp-Programming/issues/12","id":119392106,"number":12,"title":"Alist example not quite right","user":{"login":"franburstall","id":5726790,"avatar_url":"https://avatars.githubusercontent.com/u/5726790?v=3","gravatar_id":"","url":"https://api.github.com/users/franburstall","html_url":"https://github.com/franburstall","followers_url":"https://api.github.com/users/franburstall/followers","following_url":"https://api.github.com/users/franburstall/following{/other_user}","gists_url":"https://api.github.com/users/franburstall/gists{/gist_id}","starred_url":"https://api.github.com/users/franburstall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/franburstall/subscriptions","organizations_url":"https://api.github.com/users/franburstall/orgs","repos_url":"https://api.github.com/users/franburstall/repos","events_url":"https://api.github.com/users/franburstall/events{/privacy}","received_events_url":"https://api.github.com/users/franburstall/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-29T22:24:07Z","updated_at":"2015-12-07T08:51:24Z","closed_at":null,"body":"Hi,\r\n\r\nYr function plist->alist creates a list of lists rather than a list of cons cells.  Should be something like:\r\n\r\n    (defun plist->alist (plist)\r\n      (if (null plist)\r\n          '()\r\n          (cons\r\n           (cons (car plist) (cadr plist))\r\n          (plist->alist (cddr plist)))))\r\n\r\n---Fran"},"comment":{"url":"https://api.github.com/repos/caiorss/Emacs-Elisp-Programming/issues/comments/162450948","html_url":"https://github.com/caiorss/Emacs-Elisp-Programming/issues/12#issuecomment-162450948","issue_url":"https://api.github.com/repos/caiorss/Emacs-Elisp-Programming/issues/12","id":162450948,"user":{"login":"franburstall","id":5726790,"avatar_url":"https://avatars.githubusercontent.com/u/5726790?v=3","gravatar_id":"","url":"https://api.github.com/users/franburstall","html_url":"https://github.com/franburstall","followers_url":"https://api.github.com/users/franburstall/followers","following_url":"https://api.github.com/users/franburstall/following{/other_user}","gists_url":"https://api.github.com/users/franburstall/gists{/gist_id}","starred_url":"https://api.github.com/users/franburstall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/franburstall/subscriptions","organizations_url":"https://api.github.com/users/franburstall/orgs","repos_url":"https://api.github.com/users/franburstall/repos","events_url":"https://api.github.com/users/franburstall/events{/privacy}","received_events_url":"https://api.github.com/users/franburstall/received_events","type":"User","site_admin":false},"created_at":"2015-12-07T08:51:24Z","updated_at":"2015-12-07T08:51:24Z","body":"OK, I agree: should have read the manual more carefully.  However, as the\nmanual says, reverse lookup with rassoc will fail on your version:\n\nELISP> (setq my-alist '((:a . 1) (:b . 2)))\n((:a . 1)\n (:b . 2))\n\nELISP> (setq yr-alist '((:a 1) (:b 2)))\n((:a 1)\n (:b 2))\n\nELISP> (rassoc 2 my-alist)\n(:b . 2)\n\nELISP> (rassoc 2 yr-alist)\nnil\n\n---Fran\n\n\n\nOn 7 December 2015 at 04:54, Caio Rordrigues <notifications@github.com>\nwrote:\n\n> You can actually, have association lists as lists of two elements or list\n> of cons cells. It works with both, your functions and mine are correct.\n> Here a example:\n>\n> ELISP> (defun plist->alist (plist)\n>   (if (null plist)\n>       '()\n>       (cons\n>        (list (car plist) (cadr plist))\n>        (plist->alist (cddr plist)))))\n> plist->alist\n> ELISP>\n> ELISP> (plist->alist (list :x 10 :y 20 :name \"point\"))\n> ((:x 10)\n>  (:y 20)\n>  (:name \"point\"))\n>\n> ELISP> (assoc :x (plist->alist (list :x 10 :y 20 :name \"point\")))\n> (:x 10)\n>\n> ELISP> (assoc :y (plist->alist (list :x 10 :y 20 :name \"point\")))\n> (:y 20)\n>\n> ELISP>\n>\n> The problem with list of cons cells is that in the first code below the it\n> becomes a single list, which makes hard to distinguish between a \"list\" or\n> cons cell (Every list is a cons cell, of the head element and the rest of\n> the list).\n>\n> ELISP> (cons :x '(1 2 3 4))\n> (:x 1 2 3 4)\n>\n> ELISP> '(:x . (1 2 3 4))\n> (:x 1 2 3 4)\n>\n> ELISP> (list :x '(1 2 3 4))\n> (:x\n>  (1 2 3 4))\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/caiorss/Emacs-Elisp-Programming/issues/12#issuecomment-162412552>\n> .\n>\n"}}