apply(3scm)
π apply(3scm) β call a procedure with a list of arguments
okay bestie, welcome to apply(3scm), straight out of the Scheme Programmer's Manual β¨. This one's lowkey iconic β it's the "I have my args in a list, don't @ me" procedure. Let's get into it π«Ά
π¦ LIBRARY
import it from whichever flavour of Scheme you're living in, queen:
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
πΈ SYNOPSIS
(apply procedure obj ... pair)
that's the whole vibe. no notes π
π DESCRIPTION
so apply calls procedure β but instead of you handing it arguments one by one like a peasant, it takes the elements of this list:
(append (list obj ...) pair)
and feeds those in as the actual arguments. that's it. that's the whole procedure. obj ... is however many objects you wanna front-load, and pair is the list that gets tacked on the end π
β RETURN VALUES
apply hands you back exactly the values that procedure returned when it got called in the manner above. no extra seasoning, no middleman nonsense β just whatever came out π₯
π EXAMPLES
(nothing here in the original, bestie β the EXAMPLES section is empty. the real examples live down in APPLICATION USAGE, keep scrolling π)
β¨ APPLICATION USAGE
okay so when do you actually reach for this? main character use case: you need to call a procedure but the set of arguments you're giving it isn't known ahead of time β so you can't just type them out. that's apply's whole moment π
it can also do a cute lil "fold" over a list of items, but only if procedure can take an arbitrary number of arguments. like this:
(apply + (list 1 2 3 4)) => 10
ate. no cap. π
π RATIONALE
(empty in the original! a mysterious queen. nothing to report π΅οΈββοΈ)
π COMPATIBILITY
(also empty β dry text, this section. we move π )
π ERRORS
this procedure can raise exceptions with these condition types, so pay attention:
&assertion(R6RS) β the wrong number of arguments got passed, or an argument was outside its domain. basically: you fumbled the args π- R7RS β the assertions described above are errors. implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically. yes, catastrophically. not a drill ππ₯
π§ SEE ALSO
(empty in the original β nothing to point you at, sadly π₯²)
πΈ STANDARDS
it's standing on business across all of these: R4RS, IEEE Scheme, R5RS, R6RS, R7RS. five for five, periodt π
π HISTORY
(empty β the lore is lost to time π)
π«Ά AUTHORS
this page is part of the scheme-manpages project! it includes materials from the RnRS documents. more info lives at https://github.com/schemedoc/manpages/ β go show them love π
and that's the whole page, bestie π¦ this was apply(3scm), dated 2022-02-01, from the Scheme Programmer's Manual β mwah, go call some procedures π
β¨
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright Β© 2022 Ben Davenport-Ray
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms