mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
core/Array.carp: fix minimum and maximum for non-primitive types
This commit is contained in:
parent
e3b72d4179
commit
4cf918f71a
@ -116,7 +116,7 @@ Returns `Nothing` if the array is empty.")
|
||||
(do
|
||||
(for [i 1 n]
|
||||
(let [x @(nth xs i)]
|
||||
(if (< result x)
|
||||
(if (< &result &x)
|
||||
(set! result x)
|
||||
())))
|
||||
result)))
|
||||
@ -129,7 +129,7 @@ Returns `Nothing` if the array is empty.")
|
||||
(do
|
||||
(for [i 1 n]
|
||||
(let [x @(nth xs i)]
|
||||
(if (> result x)
|
||||
(if (> &result &x)
|
||||
(set! result x)
|
||||
())))
|
||||
result)))
|
||||
|
@ -83,6 +83,14 @@
|
||||
1
|
||||
(minimum &(range 1 10 1))
|
||||
"minimum works as expected")
|
||||
(assert-equal test
|
||||
&(Pair.init 2 1)
|
||||
&(maximum &[(Pair.init 1 3) (Pair.init 2 1) (Pair.init 2 0)])
|
||||
"maximum works on pairs")
|
||||
(assert-equal test
|
||||
&(Pair.init 1 3)
|
||||
&(minimum &[(Pair.init 1 3) (Pair.init 2 1) (Pair.init 2 0)])
|
||||
"minimum works on pairs")
|
||||
(assert-equal test
|
||||
55
|
||||
(sum &(range 1 10 1))
|
||||
|
Loading…
Reference in New Issue
Block a user