openlang

Exchange a pair of Elisp bindings

Say I've got

(setq left 3
      right 4)

What's a neat way to exchange what left and right hold, avoiding an extra temporary binding?

The conversation continues 3

Follow the reasoning
  1. Permalink

    As far as I remember, if using cl-lib is acceptable, try:

    (cl-rotatef
     left right)

    Note that the approach here comes from Common Lisp.

  2. Permalink

    For integer values:

    (setq left (logxor left right))
    (setq right (logxor left right))
    (setq left (logxor left right))

    :)

Other sides of the same question

  1. Using MATLAB through Google Colab

    Can MATLAB commnads be used from Google Colab (cloud-hosted Jupyter)? For instance, I'd like to invoke Risk Management Toolbo…

    Replies 2Latest activity matlab
  2. Can gdb set a breakpoint for an assembly instruction using its address?

    My attempt: apparently this command does not exist, though. Can gdb do something like this?

    Replies 2Latest activity assembly
  3. Can Playwright assertions allow either of two possible text values?

    I'd like to verify that the text contains either one or two: Can this be made to work in Playwright? Could the same thing als…

    Replies 2Latest activity typescript