dosequenceGBBopen Toolsdotted-lengthdosublistsGoTo Top

dosublists   (var list-form [result-form]) declaration* {tag | form}* => result*or nil[Macro]

Purpose
A dolist-style iterator for successive sublists of a list.

Package   :gbbopen-tools

Module   :gbbopen-tools

Arguments and values

var     A variable symbol
list-form     A form that evaluates to a proper list
result-form     A form
declarations     A declare expression (not evaluated)
tag     A go tag (not evaluated)
form     A form
results     The values returned by evaluating the last form

Returns
If a return or return-from form is executed, then the values passed from that form are returned; otherwise, the values returned by evaluating the result-form are returned, or nil if there is no result-form.

Description
The body of dosublists is like a tagbody. Dosublists evaluates list-form, which should produce a proper list. It then executes the body once for each successive sublist in the list, with var bound to the sublist.

The scope of the binding of var does not include the list-form, but it does include the result-form.

See also
    dosequence

Examples

  > (dosublists (sublist '(1 2 3)) (print sublist))
  (1 2 3)
  (2 3) 
  (3) 
  nil
  > (dosublists (sublist '(1 2 3) (print "Done")) (print sublist))
  (1 2 3)
  (2 3) 
  (3) 
  "Done"
  >


The GBBopen Project


dosequenceGBBopen Toolsdotted-lengthdosublistsGoTo Top