Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.
Next: Procedure Properties, Previous: Case-lambda, Up: Procedures [Contents][Index]
As a functional programming language, Scheme allows the definition of higher-order functions, i.e., functions that take functions as arguments and/or return functions. Utilities to derive procedures from other procedures are provided and described below.
Return a procedure that accepts any number of arguments and returns value.
(procedure? (const 3)) ⇒ #t ((const 'hello)) ⇒ hello ((const 'hello) 'world) ⇒ hello
Return a procedure with the same arity as proc that returns the
not
of proc’s result.
(procedure? (negate number?)) ⇒ #t ((negate odd?) 2) ⇒ #t ((negate real?) 'dream) ⇒ #t ((negate string-prefix?) "GNU" "GNU Guile") ⇒ #f (filter (negate number?) '(a 2 "b")) ⇒ (a "b")
Compose proc1 with the procedures proc2 … such that the last proc argument is applied first and proc1 last, and return the resulting procedure. The given procedures must have compatible arity.
(procedure? (compose 1+ 1-)) ⇒ #t ((compose sqrt 1+ 1+) 2) ⇒ 2.0 ((compose 1+ sqrt) 3) ⇒ 2.73205080756888 (eq? (compose 1+) 1+) ⇒ #t ((compose zip unzip2) '((1 2) (a b))) ⇒ ((1 2) (a b))
Return X.
When value is #f
, return #f
. Otherwise, return
(proc value)
.