std.lib.bin.type
bigint-to-bitset
added in 3.0
(bigint-to-bitset x)creates a bitset from a bigint
(-> (bigint-to-bitset 9223372036854775808N) (bitset-to-bitseq)) => (conj (vec (repeat 63 0)) 1)
bitseq
added in 3.0
(bitseq obj)converts to a bitseq binary representation
(binary/bitseq (byte-array 49)) => 1 0 0 0 1 1
bitseq-to-bitset
added in 3.0
(bitseq-to-bitset bseq)creates a bitset from a binary sequence
(bitseq-to-bitset 1 0 0 0 1 1) ;; => #bs1 0 0 0 1 1
bitseq-to-bitstr
added in 3.0
(bitseq-to-bitstr bseq)creates a bitstr from a binary sequence
(bitseq-to-bitstr 1 0 0 0 1 1) => “100011”
bitseq-to-number
added in 3.0
(bitseq-to-number arr)(bitseq-to-number arr factor)creates a number from a binary sequence
(bitseq-to-number 1 0 0 0 1 1) => 49
(bitseq-to-number (repeat 10 1)) => 1023
bitset
added in 3.0
(bitset obj)converts to a bitset binary representation
(-> (binary/bitset “100011”) (bitset-to-bitseq)) => 1 0 0 0 1 1
bitset-to-bitseq
added in 3.0
(bitset-to-bitseq bs)(bitset-to-bitseq bs length)creates a binary sequence from a bitset (-> (bitseq-to-bitset 1 0 0 0 1 1) (bitset-to-bitseq)) => 1 0 0 0 1 1
bitset-to-bytes
added in 3.0
(bitset-to-bytes bs)creates a byte array from a bitset
(-> (bitseq-to-bitset 1 0 0 0 1 1) (bitset-to-bytes) seq) => 49
bitstr
added in 3.0
(bitstr obj)converts to a bitstr binary representation
(binary/bitstr (byte-array 49)) => “100011”
bitstr-to-bitseq
added in 3.0
(bitstr-to-bitseq s)creates a binary sequence from a bitstr
(bitstr-to-bitseq “100011”) => 1 0 0 0 1 1
bitstr?
added in 3.0
(bitstr? x)checks if a string consists of only 1s and 0s
(bitstr? “0101010101”) => true
(bitstr? “hello”) => false
bytes
added in 3.0
(bytes obj)converts to a byte array binary representation
(-> (binary/bytes “100011”) (seq)) => 49
bytes-to-bitset
added in 3.0
(bytes-to-bitset arr)creates a bitset from bytes
(-> (byte-array 49) (bytes-to-bitset) (bitset-to-bitseq 8)) => 1 0 0 0 1 1 0 0
channel
added in 3.0
(channel obj)creates a channel from various representations
(channel (fs/file “project.clj”)) => java.nio.channels.Channel
input-stream
added in 3.0
(input-stream obj)creates an inputstream from various representations
(input-stream 9223372036854775808N) => java.io.ByteArrayInputStream
long-to-bitseq
added in 3.0
(long-to-bitseq x)(long-to-bitseq x m)creates a binary sequence from a long
(long-to-bitseq 1023) => 1 1 1 1 1 1 1 1 1 1
(long-to-bitseq 49 8) => 1 0 0 0 1 1 0 0
number
added in 3.0
(number obj)converts to a number binary representation
(binary/number “100011”) => 49
output-stream
added in 3.0
(output-stream obj)creates an inputstream from various representations
(output-stream (fs/file “project.clj”)) => java.io.FileOutputStream