min(3scm)
π min(3scm) β the Scheme Programmer's Manual, but make it group chat π
Okay so bestie, welcome to min(3scm) from the Scheme Programmer's Manual β yes the whole manual, and yes we're doing the max/min page together because they're literally inseparable, iykyk. π«Ά
β¨ NAME β¨
max, min β find the maximum or minimum argument. That's it. That's the whole job. Iconic behaviour, no notes. π
π LIBRARY π
Here's where you import these babies from, depending on which Scheme flavour you're living in:
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
(import (rnrs arithmetic fixnums)) ;R6RS
(import (rnrs arithmetic flonums)) ;R6RS
Like, pick your era, bestie. All valid. π
πΈ SYNOPSIS πΈ
(max x1 x2 ...)
(fxmax fx1 fx2 ...) ;R6RS
(flmax fl1 fl2 ...) ;R6RS
(min x1 x2 ...)
(fxmin fx1 fx2 ...) ;R6RS
(flmin fl1 fl2 ...) ;R6RS
Six procedures. Two jobs. Maximum chaos (affectionate). β¨
π« DESCRIPTION π«
These procedures return the maximum or minimum of their arguments. Lowkey the simplest thing ever, but there's lore, so let's get into it. π§
π Generic versions π
For any real number object x that is not a NaN:
(max +inf.0 x) => +inf.0
(min -inf.0 x) => -inf.0
Also! If any argument is inexact, then the result is also inexact β unless the procedure can prove that the inaccuracy is not large enough to affect the result, which (ngl) is only possible in unusual implementations. So don't count on it, bestie. π
π¦ Fixnum versions π¦
The arguments and the return value are fixnums. There are no special cases. Clean, simple, no drama β the way I wish my life was. π
π Flonum versions π
The arguments are the return value are flonums. (Yes, that's exactly how the original says it, we're keeping it.) And heads up: if one or more of the arguments is a NaN then a NaN is returned. π«Ά
π RETURN VALUES π
Returns a single number object. One number. That's it. Slay. β¨
π₯ EXAMPLES π₯
(max 3 4) => 4
(max 3.9 4) => 4.0
(max 42 +nan.0) => +nan.0
Look at (max 3.9 4) giving 4.0 and not 4 β that's the inexactness thing from before doing its little dance. π
β COMPATIBILITY β
The generic versions of these procedures work the same in all Scheme revisions. Fr fr, no cap, portable across every report. π
π ERRORS π
This procedure can raise exceptions with the following condition types β pay attention bestie, this is the part where things get real:
&assertion(R6RS) β the wrong number of arguments was passed, or an argument was outside its domain. π&implementation-restriction(R6RS) β may be raised ifminormaxis used to compare number objects of mixed exactness, and the numerical value of the result cannot be represented as an inexact number object without loss of accuracy. So like, it might yell at you, might not. Vibe check pending. π- R7RS β the reasons for
&assertiondescribed above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically. Fail catastrophically. Not me hyping up a footnote. π It is not specified how implementations should handle the&implementation-restrictioncase described above, but the program may be stopped. So yeah. It might just. Stop. π
π SEE ALSO π
<(3scm) β go read that one too, bestie, it's the sibling page. π«Ά
π STANDARDS π
R4RS, IEEE Scheme, R5RS, R6RS, R7RS. The whole squad. π
π°οΈ HISTORY π°οΈ
The generic versions of these procedures are in all Scheme reports since R2RS. Early Scheme built on top of MacLISP also provided them β so they're genuinely vintage, like find-your-grandma's-records vintage. π
The fixnum and flonum versions are new in R6RS. Fresh drop. β¨
π AUTHORS π
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/. Shoutout to the maintainers, absolute icons. π«Ά
π BUGS π
IEEE Scheme accidentally omitted min. That's it. That's the bug. A whole procedure justβ¦ not invited to the function list. Not me feeling genuinely bad for min like it's a group-chat exclusion. ππ
Okay so that's the whole page, and yes, every single option, value, condition type, example and reference made it in β the vibe changed, the facts did not. π
Signing off from min(3scm), dated 2022-03-26, part of the scheme-manpages project (the one that lives at https://github.com/schemedoc/manpages/) β mwah, go find the max of your day, bestie. πππ¦
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2022 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms