remq(3scm)

πŸ“¦ version 0-unstable-2024-02, in nixpkgs unstable

πŸ’– remq, remv, remove, remp β€” the "get that out of my list" girlies πŸ’–

okay bestie, so this is a 3scm manpage from the Scheme Programmer's Manual, and it's literally all about four little procedures that ghost elements out of your list 🫢


🌸 LIBRARY 🌸

(import (rnrs))                     ;R6RS
(import (rnrs lists))               ;R6RS

like, pick your import, both are giving R6RS πŸ’…


✨ SYNOPSIS ✨

(remq obj list)
(remv obj list)
(remove obj list)
(remp proc list)

four icons, one job πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the vibe: each of these procedures returns a list of the elements of list that do not satisfy a given condition. it's giving "blocked, deleted, unfollowed" ✨

remp applies proc to each element of list and returns a list of the elements of list for which proc returned #f. the other procedures return a list of the elements that are not obj.

comparison tea β˜•:

  • remq uses eq?(3scm) to compare obj with the elements of list
  • remv uses eqv?(3scm)
  • remove uses equal?(3scm)

the elements of the result list are in the same order as they appear in the input list β€” no chaotic reshuffling, we're not animals πŸ’… If multiple returns occur, the return values returned by earlier returns are not mutated.

Proc should accept one argument and return a single value. Proc should not mutate list. Proc is always called in the same dynamic environment as this procedure itself. no cap, that matters πŸ‘‘


πŸŽ€ IMPLEMENTATION NOTES πŸŽ€

the implementation must check the restrictions on proc to the extent performed by applying it as described above. An implementation may check whether proc is an appropriate argument before applying it. so like, it's allowed to vibe-check your proc early πŸ™ˆ


⭐ RETURN VALUES ⭐

these procedures return a single value; a list. that's it, that's the whole reveal πŸ¦‹


πŸ”₯ EXAMPLES πŸ”₯

(remp even? '(3 1 4 1 5 9 2 6 5))
        =>  (3 1 1 5 9 5)

bye bye evens πŸ‘‹

(remove 1 '(3 1 4 1 5 9 2 6 5))
        =>  (3 4 5 9 2 6 5)
(remv 1 '(3 1 4 1 5 9 2 6 5))
        =>  (3 4 5 9 2 6 5)
(remq 'foo '(bar foo baz))
        =>  (bar baz)

that last one just ate and left no crumbs 😭


🌈 COMPATIBILITY 🌈

these procedures are unique to R6RS. like, exclusive. iykyk πŸ’…


πŸ’€ ERRORS πŸ’€

these procedures can raise exceptions with the following condition types:

  • &assertion (R6RS) β€” the wrong number of arguments was passed or an argument was outside its domain. so like, if you fumble the args, it WILL tell you 🫢

πŸ‘‘ SEE ALSO πŸ‘‘

filter(3scm) β€” the main character this whole page is quietly competing with ngl


πŸ’œ STANDARDS πŸ’œ

R6RS. periodt.


🧚 HISTORY 🧚

these procedures first appeared in R6RS. they've been iconic since day one ✨


πŸ’– 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/.


and yeah, this whole glow-up is from the Scheme Programmer's Manual, dated 2022-05-07 β€” remq(3scm) forever, bestie πŸ“πŸ’…

bye love u, go remove some elements πŸ¦‹βœ¨

πŸ“¦ where this page comes from