remq(3scm) Scheme Programmer's Manual remq(3scm)

remq, remv, remove, remp - remove elements from a list

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

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

Each of these procedures returns a list of the elements of list that do not satisfy a given condition.

The remp procedure 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.

The remq procedure uses eq?(3scm) to compare obj with the elements of list, while remv uses eqv?(3scm) and remove uses equal?(3scm).

The elements of the result list are in the same order as they appear in the input list. 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.

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.

These procedures return a single value; a list.

(remp even? '(3 1 4 1 5 9 2 6 5))
        =>  (3 1 1 5 9 5)
(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)

These procedures are unique to R6RS.

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.

filter(3scm)

R6RS

These procedures first appeared in R6RS.

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.

2022-05-07