Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
1
Task/Identity-matrix/Clojure/identity-matrix-1.clj
Normal file
1
Task/Identity-matrix/Clojure/identity-matrix-1.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
'( (0 1) (2 3) )
|
||||
6
Task/Identity-matrix/Clojure/identity-matrix-2.clj
Normal file
6
Task/Identity-matrix/Clojure/identity-matrix-2.clj
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(defn identity-matrix [n]
|
||||
(let [row (conj (repeat (dec n) 0) 1)]
|
||||
(vec
|
||||
(for [i (range 1 (inc n))]
|
||||
(vec
|
||||
(reduce conj (drop i row ) (take i row)))))))
|
||||
2
Task/Identity-matrix/Clojure/identity-matrix-3.clj
Normal file
2
Task/Identity-matrix/Clojure/identity-matrix-3.clj
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
=> (identity-matrix 5)
|
||||
[[1 0 0 0 0] [0 1 0 0 0] [0 0 1 0 0] [0 0 0 1 0] [0 0 0 0 1]]
|
||||
4
Task/Identity-matrix/Clojure/identity-matrix-4.clj
Normal file
4
Task/Identity-matrix/Clojure/identity-matrix-4.clj
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(defn identity-matrix [n]
|
||||
(take n
|
||||
(partition n (dec n)
|
||||
(cycle (conj (repeat (dec n) 0) 1)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue