File tree Expand file tree Collapse file tree 2 files changed +0
-44
lines changed Expand file tree Collapse file tree 2 files changed +0
-44
lines changed Original file line number Diff line number Diff line change @@ -2337,29 +2337,3 @@ pub fn max(
2337
2337
}
2338
2338
} )
2339
2339
}
2340
-
2341
- /// Takes a list and a comparator, and returns the minimum element in the list
2342
- ///
2343
- ///
2344
- /// ## Example
2345
- ///
2346
- /// ```gleam
2347
- /// range(1, 10) |> list.int(int.compare)
2348
- /// // -> Ok(1)
2349
- /// ```
2350
- ///
2351
- /// ```gleam
2352
- /// ["a", "c", "b"] |> list.int(string.compare)
2353
- /// // -> Ok("a")
2354
- /// ```
2355
- pub fn min (
2356
- over list : List ( a) ,
2357
- with compare : fn ( a, a) -> Order ,
2358
- ) -> Result ( a, Nil ) {
2359
- reduce ( over : list , with : fn ( acc , other ) {
2360
- case compare ( acc , other ) {
2361
- order . Lt -> acc
2362
- _ -> other
2363
- }
2364
- } )
2365
- }
Original file line number Diff line number Diff line change @@ -1299,21 +1299,3 @@ pub fn max_test() {
1299
1299
|> list . max ( string . compare )
1300
1300
|> should . equal ( Ok ( "c" ) )
1301
1301
}
1302
-
1303
- pub fn min_test ( ) {
1304
- [ ]
1305
- |> list . min ( int . compare )
1306
- |> should . equal ( Error ( Nil ) )
1307
-
1308
- [ 1 , 3 , 2 ]
1309
- |> list . min ( int . compare )
1310
- |> should . equal ( Ok ( 1 ) )
1311
-
1312
- [ -1.0 , 1.2 , 1.104 ]
1313
- |> list . min ( float . compare )
1314
- |> should . equal ( Ok ( -1.0 ) )
1315
-
1316
- [ "a" , "c" , "b" ]
1317
- |> list . min ( string . compare )
1318
- |> should . equal ( Ok ( "a" ) )
1319
- }
You can’t perform that action at this time.
0 commit comments