From 29e88b3ea3e13c7c86c707b6119cadad669e55aa Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 10 May 2016 01:31:52 +0000 Subject: unposted: Commit forgotten part of users/21256. --- Functions/Math/.distfiles | 2 ++ Functions/Math/zmathfunc | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Functions/Math/.distfiles create mode 100644 Functions/Math/zmathfunc (limited to 'Functions') 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 + -- cgit 1.4.1