This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-28
Channels
- # adventofcode (2)
- # bangalore-clj (3)
- # beginners (171)
- # boot (28)
- # chestnut (3)
- # cljs-dev (20)
- # cljsjs (5)
- # clojure (280)
- # clojure-austin (1)
- # clojure-czech (1)
- # clojure-dev (9)
- # clojure-dusseldorf (2)
- # clojure-greece (20)
- # clojure-italy (6)
- # clojure-poland (16)
- # clojure-russia (7)
- # clojure-serbia (4)
- # clojure-sg (1)
- # clojure-spec (18)
- # clojure-uk (153)
- # clojurescript (57)
- # core-async (9)
- # cursive (21)
- # data-science (29)
- # datomic (18)
- # dirac (8)
- # docker (6)
- # duct (1)
- # emacs (50)
- # fulcro (15)
- # hoplon (56)
- # klipse (3)
- # leiningen (14)
- # lumo (1)
- # off-topic (5)
- # onyx (13)
- # other-languages (14)
- # pedestal (1)
- # perun (5)
- # planck (17)
- # re-frame (10)
- # reagent (2)
- # ring (1)
- # spacemacs (51)
- # sql (14)
- # test-check (16)
- # testing (1)
- # unrepl (93)
dumb q, how do I mutate (in-place) a list value?
set/setq don't seem apt for the job as one cannot (set (list 2) (list 3))
I think it can make sense? consider a javascript array you can mutate its length from 10 to 0 and back right?
>you can mutate its length from 10 to 0 and back right? you can emulate this in elisp by cadr-ing 🙂, but your HAVE to have a symbol which you are trying to bind to a new value (with a reduced len)
ok, so I'm asking if there's a readily available function that provides a behavior equivalent to "mutate this whole list setting it to some-other-list
"
(defvar a '(1 2 3))
(defun mutate-it (coll)
(setq coll (cdr coll))
(setq coll (cdr coll))
(setq coll (cdr coll))
(push "foo" coll)
(push "bar" coll)
(push "baz" coll))
(mutate-it a)
@vemv there's push
: https://www.gnu.org/software/emacs/manual/html_node/elisp/List-Variables.html
and pop
: https://www.gnu.org/software/emacs/manual/html_node/elisp/List-Elements.html
^ that works, but in certain usages I need to (-clone ...)
(dash.el library) things first. couldn't figure out exactly why