bit-set

function/macrosince v0.0-927 clojure.core/bit-setEdit
(bit-set x n)

Details:

Set bit at index n. Same as x | (1 << y) in JavaScript.


Examples:

Bits can be entered using radix notation:

(bit-set 2r1100 1)
;;=> 14
;; 14 = 2r1110

Same number in decimal:

(bit-set 12 1)
;;=> 14

See Also:


Source docstring:
Set bit at index n
Function code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn bit-set
  [x n]
  (cljs.core/bit-set x n))

Macro code @ clojurescript:src/main/clojure/cljs/core.cljc
(core/defmacro ^::ana/numeric bit-set [x n]
  (core/list 'js* "(~{} | (1 << ~{}))" x n))