Skip to content

Commit

Permalink
added matrix module (just transpose function yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
juerg committed Dec 17, 2023
1 parent 85992d5 commit b553ac8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static boolean isValidModule(final VncKeyword module) {
"jsonl",
"kira",
"math",
"matrix",
"maven",
"mercator",
"mimetypes",
Expand Down
46 changes: 46 additions & 0 deletions src/main/resources/com/github/jlangch/venice/matrix.venice
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
;;;; __ __ _
;;;; \ \ / /__ _ __ (_) ___ ___
;;;; \ \/ / _ \ '_ \| |/ __/ _ \
;;;; \ / __/ | | | | (_| __/
;;;; \/ \___|_| |_|_|\___\___|
;;;;
;;;;
;;;; Copyright 2017-2023 Venice
;;;;
;;;; Licensed under the Apache License, Version 2.0 (the "License");
;;;; you may not use this file except in compliance with the License.
;;;; You may obtain a copy of the License at
;;;;
;;;; http://www.apache.org/licenses/LICENSE-2.0
;;;;
;;;; Unless required by applicable law or agreed to in writing, software
;;;; distributed under the License is distributed on an "AS IS" BASIS,
;;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;;;; See the License for the specific language governing permissions and
;;;; limitations under the License.

;;;; 2D-Matrix functions

(ns matrix)

(defn
^{ :arglists '(
"(matrix/transpose m)")
:doc """
Transposes a matrix. A matrix is a vector of vectors [[1 2] [3 4]]
"""
:examples (list
"""
(do
(load-module :matrix)

;; | 1 2 3 | => | 1 4 |
;; | 4 5 6 | | 2 5 |
;; | 3 6 |
(matrix/transpose [[1 2 3]
[4 5 6]]))
""" ) }

transpose [m]

(apply map vector m))

0 comments on commit b553ac8

Please sign in to comment.