Files
CljElixir/stubs/Tuple.clj
2026-03-09 23:09:46 -04:00

40 lines
1017 B
Clojure

(ns Tuple
"Elixir Tuple module — operations on tuples.
In CljElixir: (Tuple/to-list tup), (Tuple/append tup elem), etc.
Tuples are fixed-size, contiguous containers on the BEAM.
Create tuples with #el[...] syntax in CljElixir.")
(defn to-list
"Converts a tuple to a list.
(Tuple/to-list #el[1 2 3]) ;=> [1 2 3]"
[tuple])
(defn append
"Appends `value` to `tuple`.
(Tuple/append #el[1 2] 3) ;=> #el[1 2 3]"
[tuple value])
(defn insert-at
"Inserts `value` at `index` in `tuple`.
(Tuple/insert-at #el[1 2 3] 1 :a) ;=> #el[1 :a 2 3]"
[tuple index value])
(defn delete-at
"Deletes element at `index` from `tuple`.
(Tuple/delete-at #el[1 2 3] 1) ;=> #el[1 3]"
[tuple index])
(defn duplicate
"Creates a tuple with `data` repeated `size` times.
(Tuple/duplicate :ok 3) ;=> #el[:ok :ok :ok]"
[data size])
(defn product
"Returns the product of all numeric elements in the tuple."
[tuple])
(defn sum
"Returns the sum of all numeric elements in the tuple."
[tuple])