about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2016-05-10 01:31:52 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2016-05-10 18:39:18 +0000
commit29e88b3ea3e13c7c86c707b6119cadad669e55aa (patch)
tree18b8f6ac84635ea6fb11e33ee95ea21b0d5bdeac
parentf09c00bca5f6d634515e3ad5139813a64bfe83d8 (diff)
downloadzsh-29e88b3ea3e13c7c86c707b6119cadad669e55aa.tar.gz
zsh-29e88b3ea3e13c7c86c707b6119cadad669e55aa.tar.xz
zsh-29e88b3ea3e13c7c86c707b6119cadad669e55aa.zip
unposted: Commit forgotten part of users/21256.
-rw-r--r--ChangeLog3
-rw-r--r--Functions/Math/.distfiles2
-rw-r--r--Functions/Math/zmathfunc34
3 files changed, 39 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 2abb44b42..5caeeccef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2016-05-10  Daniel Shahaf  <d.s@daniel.shahaf.name>
 
+	* unposted: Functions/Math/.distfiles, Functions/Math/zmathfunc:
+	Commit forgotten part of users/21256.
+
 	* 38453: Completion/Debian/Command/_apt: Complete
 	${package}/${release} for 'source' and 'build-dep', too.
 
diff --git a/Functions/Math/.distfiles b/Functions/Math/.distfiles
new file mode 100644
index 000000000..f03668b3a
--- /dev/null
+++ b/Functions/Math/.distfiles
@@ -0,0 +1,2 @@
+DISTFILES_SRC='
+'
diff --git a/Functions/Math/zmathfunc b/Functions/Math/zmathfunc
new file mode 100644
index 000000000..4ff40700d
--- /dev/null
+++ b/Functions/Math/zmathfunc
@@ -0,0 +1,34 @@
+#autoload
+
+zsh_math_func_min() {
+  local result=$1
+  shift
+  local arg
+  for arg ; do
+    (( $arg < result )) && result=$arg
+  done
+  (( result )) # return
+}
+functions -M min 1 -1 zsh_math_func_min # at least one argument
+
+zsh_math_func_max() {
+  local result=$1
+  shift
+  local arg
+  for arg ; do
+    (( $arg > result )) && result=$arg
+  done
+  (( result )) # return
+}
+functions -M max 1 -1 zsh_math_func_max # at least one argument
+
+zsh_math_func_sum() {
+  local sum
+  local arg
+  for arg ; do
+    (( sum += $arg ))
+  done
+  (( sum ))
+}
+functions -M sum 0 -1 zsh_math_func_sum
+