[previous] [up] [next]     [contents] [index]
Next: Inflating Compressed Data Up: MzLib Libraries Previous: Filesystem

Functions

Files: functio.ss, functiou.ss, functior.ss, functios.ss, functioc.ss
Signature: mzlib:function^
Unit: mzlib:function@

The procedures first, second, third, fourth, fifth, sixth, seventh, and eighth access the corresponding element from a list. The procedure rest is a synonym for cdr, cons? is a synonym for pair?, empty is a synonym for null, and empty? is a synonym for null?.



(assf f l) PROCEDURE

Applies f to each element of l (from left to right) until f returns a true value for some element, in which case that element is returned. If f does not return a true value for any element of l, #f is returned.



(build-list n f) PROCEDURE

Creates a list of n elements by applying f to the integers from 0 to tex2html_wrap_inline13224 in order, where n is a non-negative integer. The ith element of the resulting list is (f (- i 1)).



(build-string n f) PROCEDURE

Creates a string of length n by applying f to the integers from 0 to tex2html_wrap_inline13224 in order, where n is a non-negative integer and f returns a character for the n invocations. The ith character of the resulting string is (f (- i 1)).



(build-vector n f) PROCEDURE

Creates a vector of n elements by applying f to the integers from 0 to tex2html_wrap_inline13224 in order, where n is a non-negative integer. The ith element of the resulting vector is (f (- i 1)).



(compose f g) PROCEDURE

Returns a procedure that takes x and returns (call-with-values (lambda () (g x)) f).



(dynamic-disable-break thunk) PROCEDURE

Invokes thunk and returns the result. During the application of thunk, user breaks are disabled.



(dynamic-wind/protect-break pre-thunk value-thunk post-thunk) PROCEDURE

Like dynamic-wind (see section 8.4), except that the pre-thunk and post-thunk procedures are protected from a user-break. (Users breaks are allowed in value-thunk only if breaking is otherwise allowed.)



(filter f l) PROCEDURE

Applies f to each element in l (from left to right) and returns a new list that is the same as l, but omitting all the elements for which f returned #f.



(foldl f init l tex2html_wrap_inline12552 ) PROCEDURE

Like map, foldl applies a procedure f to the elements of one or more lists. While map combines the return values into a list, foldl combines the return values in an abitrary way that is determined by f.

If foldl is called with n lists, the f procedure takes n+1 arguments. The extra value is the combined return values so far. The f procedure is initially invoked with the first item of each list; the final argument is init. In subsequent invocations of f, the last argument is the return value from the previous invocation of f. The input lists are traversed from left to right, and the result of the whole foldl application is the result of the last application of f. (If the lists are empty, the result is init.)

For example, reverse can be defined in terms of foldl:

  (define reverse
    (lambda (l)
      (foldl cons '() l))) 



(foldr f init l tex2html_wrap_inline12552 ) PROCEDURE

Like foldl, but the lists are traversed from right to left.

For example, a restricted map (that works only on single-argument procedures) can be defined in terms of foldr:

  (define simple-map
    (lambda (f list)
      (foldr (lambda (v l) (cons (f v) l)) '() list))) 



(identity x) PROCEDURE

Returns x.



(ignore-errors thunk) PROCEDURE

Invokes thunk and returns the result. If an error occurs during the application of thunk, no error is reported and void is returned.



(last-pair list) PROCEDURE

Returns the last pair in list, raising an error if list is not a pair (but list does not have to be a proper list).



(loop-until start done? next f) PROCEDURE

Repeatedly invokes the f procedure until the done? procedure returns #t. The procedure is best described by its implementation:

  (define loop-until
    (lambda (start done? next f)
      (let loop ([i start])
        (unless (done? i)
          (f i)
          (loop (next i)))))) 



(make-single-threader) PROCEDURE

Returns a new procedure that takes any thunk and applies it. When this procedure is applied to any collection of thunks by any collection of threads, the thunks are applied sequentially across all threads.



(memf f l) PROCEDURE

Applies f to each element of l (from left to right) until f returns a true value for some element, in which case the tail of l starting with that element is returned. If f does not return a true value for any element of l, #f is returned.



(quicksort list less-than?) PROCEDURE

Sorts list using the comparison procedure less-than?. This implementation is not stable (i.e., if two elements in the input are ``equal,'' their relative positions in the output may be reversed).



(remove item list [equal?]) PROCEDURE

Returns list without the first instance of item, where an instance is found by comparing item to the list items using equal?. The default value for equal? is equal?. When equal? is invoked, item is the first argument.



(remove* items list [equal?]) PROCEDURE

Like remove, except that the first argument is a list of items to remove, instead of a single item.



(remq item list) PROCEDURE

Calls remove with eq? as the comparison procedure.



(remq* item list) PROCEDURE

Calls remove* with eq? as the comparison procedure.



(remv item list) PROCEDURE

Calls remove with eqv? as the comparison procedure.



(remv* item list) PROCEDURE

Calls remove* with eqv? as the comparison procedure.


[previous] [up] [next]     [contents] [index]
Next: Inflating Compressed Data Up: MzLib Libraries Previous: Filesystem

PLT