BANNER
PrevChapter 2Next

Procedure

compose

(compose f1 f2)
;; Make a function equivalent to applying `f2' to its arguments and
;; `f1' to the result.
 (define (compose f1 f2)
   (lambda (#!rest rest) (f1 (apply f2 rest))))

const

(const c)
;; Constant function evaluating to `c'.
(define (const c)
  (lambda (#!rest rest) c))

curry

(curry f arg)
;; Partially apply two-argument function `f' to `arg', returning a
;; one-argument function.
(define (curry f arg)
  (lambda (a) (f arg a)))

curryn

(curryn f rest)
;; n-ary variant
(define (curryn f #!rest rest)
  (lambda (#!rest args)
    (apply f (append rest args))))

foldl

(foldl f zero xs)
;; Fold left with function `f' over list `xs' with the given `zero'
;; value.  (Like DSSSL `reduce' but normal arg order.)
(define (foldl f zero xs)
  (if (null? xs)
      zero
      (foldl f (f zero (car xs)) (cdr xs))))

foldl1

(foldl1 f xs)
;; Fold left with list car as zero.
(define (foldl1 f xs)
  (cond ((null? xs)
         '())
        ((null? (cdr xs))
         (car xs))
        (else (foldl f (car xs) (cdr xs)))))

foldr

(foldr f zero xs)
;; Fold right, as above.
(define (foldr f zero xs)
  (if (null? xs)
      zero
      (f (car xs) (foldl f zero (cdr xs)))))

id

(id arg)

Returns arg.

(define (id arg) arg)

PrevHomeNext
Flow ObjectUpDebugging