diff options
author | Ori Bernstein <ori@eigenstate.org> | 2014-06-21 13:20:34 -0400 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2014-06-21 13:20:34 -0400 |
commit | f19346b49ebab6e9b8838f83f2aa51a98bd082ae (patch) | |
tree | 73382bb907471e9979205da74acd64c9bc6f90d6 /libstd/extremum.myr | |
parent | 49a1983f6bea2adfbc49056ef0fec723c37f08bb (diff) | |
download | mc-f19346b49ebab6e9b8838f83f2aa51a98bd082ae.tar.gz |
Add support for padded strings.
Feeping Creaturinm.
Diffstat (limited to 'libstd/extremum.myr')
-rw-r--r-- | libstd/extremum.myr | 12 |
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 + ;; +} + |