summaryrefslogtreecommitdiff
path: root/libstd/extremum.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-06-21 13:20:34 -0400
committerOri Bernstein <ori@eigenstate.org>2014-06-21 13:20:34 -0400
commitf19346b49ebab6e9b8838f83f2aa51a98bd082ae (patch)
tree73382bb907471e9979205da74acd64c9bc6f90d6 /libstd/extremum.myr
parent49a1983f6bea2adfbc49056ef0fec723c37f08bb (diff)
downloadmc-f19346b49ebab6e9b8838f83f2aa51a98bd082ae.tar.gz
Add support for padded strings.
Feeping Creaturinm.
Diffstat (limited to 'libstd/extremum.myr')
-rw-r--r--libstd/extremum.myr12
1 files changed, 12 insertions, 0 deletions
diff --git a/libstd/extremum.myr b/libstd/extremum.myr
index c4998da..bf496ad 100644
--- a/libstd/extremum.myr
+++ b/libstd/extremum.myr
@@ -1,6 +1,7 @@
pkg std =
generic min : (a : @a::numeric, b : @a::numeric -> @a::numeric)
generic max : (a : @a::numeric, b : @a::numeric -> @a::numeric)
+ generic clamp : (a : @a::numeric, min : @a::numeric, max : @a::numeric -> @a::numeric)
;;
generic min = {a, b
@@ -18,3 +19,14 @@ generic max = {a, b
-> b
;;
}
+
+generic clamp = {a, min, max
+ if a < min
+ -> min
+ elif a > max
+ -> max
+ else
+ -> a
+ ;;
+}
+