BANNER | ||
---|---|---|

Prev | Chapter 2 | Next |

(compose |

;; 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)))) |

(curry |

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

(curryn |

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

(foldl |

;; 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 |

;; 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 |

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

Prev | Home | Next |

Flow Object | Up | Debugging |