Skip to content

Instantly share code, notes, and snippets.

@danlentz
Created October 4, 2012 06:12
Show Gist options
  • Save danlentz/3831737 to your computer and use it in GitHub Desktop.
Save danlentz/3831737 to your computer and use it in GitHub Desktop.
Iterate Clauses

Iterate Reference

ClauseOptionsDesc
INITIALLYLisp forms to execute before loop starts
AFTER-EACHLisp forms to execute after each iteration
ELSELisp forms to execute if the loop is never entered
FINALLYLisp forms to execute after loop ends
FINALLY-PROTECTEDLisp forms in an UNWIND-PROTECT after loop ends
IF-FIRST-TIMEEvaluate branch depending on whether this clause if met for the first time
FIRST-TIME-PTrue when evaluated for the first time
FIRST-ITERATION-PTrue within first iteration through the body
INProcess forms in a named Iterate block
ACCUMULATE BY&OPTIONAL INITIAL-VALUE INTOGeneralized accumulation
NUNIONING&OPTIONAL INTO AT TESTUnion into a list, destructively
UNIONING&OPTIONAL INTO AT TESTUnion into a list
APPENDING&OPTIONAL INTO ATAppend into a list
NCONCING&OPTIONAL INTO ATNconc into a list
ADJOINING&OPTIONAL INTO AT TEST RESULT-TYPEAdjoin into a list (tests for membership first)
COLLECT&OPTIONAL INTO AT RESULT-TYPECollect into a list
FINDING MINIMIZING&OPTIONAL INTOReturn value which minimizes expression
FINDING MAXIMIZING&OPTIONAL INTOReturn value which maximizes expression
FINDING SUCH-THAT&OPTIONAL INTO ON-FAILUREReturn expression when test is non-nil
THEREISReturn value of expression as soon as it is non-nil
NEVERReturn T iff expression is never non-nil
ALWAYSReturn last value iff expression is always non-nil
UNTILExit loop if test is non-nil
WHILEExit loop if test is nil
MINIMIZE&OPTIONAL INTOMinimize value of an expression
MAXIMIZE&OPTIONAL INTOMaximize value of an expression
REDUCING BY&OPTIONAL INITIAL-VALUE INTOGeneralized reduction
MULTIPLY&OPTIONAL INTOMultiply into a variable
SUM&OPTIONAL INTOSum into a variable
COUNTING&OPTIONAL INTOIncrement a variable if expression is non-nil
WITH&OPTIONAL =Bind a variable
FOR PREVIOUS&OPTIONAL INITIALLY BACKPrevious value of a variable
FOR FIRST THENSet var on first, and then on subsequent iterations
FOR =Set a variable on each iteration
FOR INITIALLY THENSet var initially, then on subsequent iterations
FOR DO-NEXTGeneral driver; VAR must be set in DO-NEXT
FOR NEXTGeneral driver; VAR is set to value of NEXT
FOR IN-STREAM&OPTIONAL USINGForms in a stream (which will be closed at the end)
FOR IN-FILE&OPTIONAL USINGForms in a file
FOR IN-PACKAGE&OPTIONAL EXTERNAL-ONLYSymbols accessible in a package
FOR IN-PACKAGES&OPTIONAL HAVING-ACCESSSymbols and their access-types in packages
FOR IN-HASHTABLEElements and keys of a hashtable
FOR INDEX-OF-STRING&OPTIONAL FROM UPFROM DOWNFROM TO DOWNTO ABOVE BELOW BY WITH-INDEXIndices of a string
FOR IN-STRING&OPTIONAL FROM UPFROM DOWNFROM TO DOWNTO ABOVE BELOW BY WITH-INDEXCharacters in a string
FOR INDEX-OF-SEQUENCE&OPTIONAL FROM UPFROM DOWNFROM TO DOWNTO ABOVE BELOW BY WITH-INDEXIndices of a sequence (vector or list)
FOR IN-SEQUENCE&OPTIONAL FROM UPFROM DOWNFROM TO DOWNTO ABOVE BELOW BY WITH-INDEXElements of a sequence (vector or list)
FOR INDEX-OF-VECTOR&OPTIONAL FROM UPFROM DOWNFROM TO DOWNTO ABOVE BELOW BY WITH-INDEXIndices of a vector
FOR IN-VECTOR&OPTIONAL FROM UPFROM DOWNFROM TO DOWNTO ABOVE BELOW BY WITH-INDEXElements of a vector
FOR IN&OPTIONAL BYElements of a list
FOR&OPTIONAL FROM UPFROM DOWNFROM TO DOWNTO ABOVE BELOW BY WITH-INDEXNumbers
FOR ON&OPTIONAL BYSublists of a list
REPEATRepeat the loop some number of times
NEXTExplicitly step a driver variable
HU.DWIM.UTIL::ORING&OPTIONAL INTO
HU.DWIM.UTIL::ANDING&OPTIONAL INTO
HU.DWIM.UTIL::SUMMING*&OPTIONAL INTOSum into a variable when expr evaluates to non nil at least once, otherwise nil
FOR INDEX-OF-MARRAY&OPTIONAL FROM UPFROM DOWNFROM TO DOWNTO ABOVE BELOW BY WITH-INDEXIndices of marray
FOR IN-MARRAY&OPTIONAL FROM UPFROM DOWNFROM TO DOWNTO ABOVE BELOW BY WITH-INDEXElements of an marray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment