SEQUENCE FUNCTIONS
These functions work on sequences -- lists, arrays, or strings.
CONCATENATE SEQUENCES
(concatenate <type> <expr> ...)
If result type is string, sequences must contain only characters.
- <type> result type, one of CONS, LIST, ARRAY, or STRING
- <expr> zero or more sequences to concatenate
- returns a sequence which is the concatenation of the arguement sequences
GET THE NTH ELEMENT OF A SEQUENCE
(elt <expr> <n>)
- <expr> the sequence
- <n> the index of element to return
- returns the element if the index is in bounds, otherwise error
APPLY FUNCTION TO SUCCESSIVE ELEMENTS
(map <type> <fcn> <expr> ...)
(map-into <target> <fcn> [<expr> ...])
- <type> result type, one of CONS, LIST, ARRAY, STRING, or NIL
- <target> destination sequence to modify
- <fcn> the function or function name
- <expr> a sequence for each argument of the function
- returns a new sequence of type <type> for MAP, and <target> for MAP-INTO.
APPLY FUNCTION TO ELEMENTS UNTIL FALSE
(every <fcn> <expr> ...)
(notevery <fcn> <expr> ...)
- <fcn> the function or function name
- <expr> a sequence for each argument of the function
- returns every returns last evaluated function result
notevery returns T if there is a NIL function result, else NIL
APPLY FUNCTION TO ELEMENTS UNTIL TRUE
(some <fcn> <expr> ...)
(notany <fcn> <expr> ...)
- <fcn> the function or function name
- <expr> a sequence for each argument of the function
- returns some returns first non-NIL function result, or NIL
notany returns NIL if there is a non-NIL function result, else T
FIND THE LENGTH OF A SEQUENCE
(length <expr>)
Note that a circular list causes an error. To detect a circular list, use LIST-LENGTH.
- <expr> the list, vector or string
- returns the length of the list, vector or string
REVERSE A SEQUENCE
(reverse <expr>)
DESTRUCTIVELY REVERSE A SEQUENCE
(nreverse <expr>)
- <expr> the sequence to reverse
- returns a new sequence in the reverse order
EXTRACT A SUBSEQUENCE
(subseq <seq> <start> [<end>])
- <seq> the sequence
- <start> the starting position (zero origin)
- <end> the ending position + 1 (defaults to end) or NIL for end of sequence
- returns the sequence between <start> and <end>
DESTRUCTIVELY SORT A SEQUENCE
(sort <seq> <test> &key :key)
- <seq> the sequence to sort
- <test> the comparison function
- :key function to apply to comparison function arguments (defaults to identity)
- returns the sorted sequence
SEARCH FOR SEQUENCE
(search <seq1> <seq2> &key :test :test-not :key :start1 :end1 :start2 :end2)
- <seq1> the sequence to search for
- <seq2> the sequence to search in
- :test the test function (defaults to eql)
- :test-not the test function (sense inverted)
- :key function to apply to test function arguments (defaults to identity)
- :start1 starting index in <seq1>
- :end1 index of end+1 in <seq1> or NIL for end of sequence
- :start2 starting index in <seq2>
- :end2 index of end+1 in <seq2> or NIL for end of sequence
- returns position of first match
REMOVE ELEMENTS FROM A SEQUENCE
(remove <expr> <seq> &key :test :test-not :key :start :end)
- <expr> the element to remove
- <seq> the sequence
- :test the test function (defaults to eql)
- :test-not the test function (sense inverted)
- :key function to apply to test function sequence argument (defaults to identity)
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns copy of sequence with matching expressions removed
REMOVE ELEMENTS THAT PASS TEST
(remove-if <test> <seq> &key :key :start :end)
REMOVE ELEMENTS THAT FAIL TEST
(remove-if-not <test> <seq> &key :key :start :end)
- <test> the test predicate
- <seq> the sequence
- :key function to apply to test function argument (defaults to identity)
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns copy of sequence with matching or non-matching elements removed
COUNT MATCHING ELEMENTS IN A SEQUENCE
(count <expr> <seq> &key :test :test-not :key :start :end)
- <expr> element to count
- <seq> the sequence
- :test the test function (defaults to eql)
- :test-not the test function (sense inverted)
- :key function to apply to each <seq> argument (defaults to identity)
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns count of matching elements
COUNT ELEMENTS THAT PASS TEST
(count-if <test> <seq> &key :key :start :end)
COUNT ELEMENTS THAT FAIL TEST
(count-if-not <test> <seq> &key :key :start :end)
- <test> the test predicate
- <seq> the sequence
- :key function to apply to test function argument (defaults to identity)
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns count of matching/non-matching elements
FIND FIRST MATCHING ELEMENT IN SEQUENCE
(find <expr> <seq> &key :test :test-not :key :start :end)
- <expr> element to search for
- <seq> the sequence
- :test the test function (defaults to eql)
- :test-not the test function (sense inverted)
- :key function to apply to each <seq> argument (defaults to identity)
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns first matching element of sequence, or NIL
FIND FIRST ELEMENT THAT PASSES TEST
(find-if <test> <seq> &key :key :start :end)
FIND FIRST ELEMENT THAT FAILS TEST
(find-if-not <test> <seq> &key :key :start :end)
- <test> the test predicate
- <seq> the sequence
- :key function to apply to test function argument (defaults to identity)
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns first element of sequence that passes/fails test, or NIL
FIND POSITION OF FIRST MATCHING ELEMENT IN SEQUENCE
(position <expr> <seq> &key :test :test-not :key :start :end)
- <expr> element to search for
- <seq> the sequence
- :test the test function (defaults to eql)
- :test-not the test function (sense inverted)
- :key function to apply to each <seq> argument (defaults to identity)
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns position of first matching element of sequence, or NIL
FIND POSITION OF FIRST ELEMENT THAT PASSES TEST
(position-if <test> <seq> &key :key :start :end)
FIND POSITION OF FIRST ELEMENT THAT FAILS TEST
(position-if-not <test> <seq> &key :key :start :end)
- <test> the test predicate
- <seq> the sequence
- :key function to apply to test function argument (defaults to identity)
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns position of first element of sequence that passes/fails test, or NIL.
DELETE ELEMENTS FROM A SEQUENCE
(delete <expr> <seq> &key :key :test :test-not :start :end)
- <expr> the element to delete
- <seq> the sequence
- :test the test function (defaults to eql)
- :test-not the test function (sense inverted)
- :key function to apply to test function sequence argument (defaults to identity)
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns the sequence with the matching expressions deleted
DELETE ELEMENTS THAT PASS TEST
(delete-if <test> <seq> &key :key :start :end)
DELETE ELEMENTS THAT FAIL TEST
(delete-if-not <test> <seq> &key :key :start :end)
- <test> the test predicate
- <seq> the sequence
- :key function to apply to test function argument (defaults to identity)
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns the sequence with matching or non-matching elements deleted
REDUCE SEQUENCE TO SINGLE VALUE
(reduce <fcn> <seq> &key :initial-value :start :end)
- <fcn> function (of two arguments) to apply to result of previous function application (or first element) and each member of sequence.
- <seq> the sequence
- :initial-value value to use as first argument in first function application rather than using the first element of the sequence.
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns if sequence is empty and there is no initial value, returns result of applying function to zero arguements. If there is a single element, returns the element. Otherwise returns the result of the last function application.
REMOVE DUPLICATES FROM SEQUENCE
(remove-duplicates <seq> &key :test :test-not :key :start :end)
- <seq> the sequence
- :test comparison function (default eql)
- :test-not comparison function (sense inverted)
- :key function to apply to test function arguments (defaults to identity)
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns copy of sequence with duplicates removed.
REPLACE ITEMS IN SEQUENCE
(fill <seq> <expr> &key :start :end)
Defined in common.lsp
- <seq> the sequence
- <expr> new value to place in sequence
- :start starting index
- :end index of end+1, or NIL for (length <seq>)
- returns sequence with items replaced with new item
REPLACE ITEMS IN SEQUENCE FROM SEQUENCE
(replace <seq1> <seq2> &key :start1 :end1 :start2 :end2)
Defined in common.lsp
- <seq1> the sequence to modify
- <seq2> sequence with new items
- :start1 starting index in <seq1>
- :end1 index of end+1 in <seq1> or NIL for end of sequence
- :start2 starting index in <seq2>
- :end2 index of end+1 in <seq2> or NIL for end of sequence
- returns first sequence with items replaced
XLISP-PLUS - Version 2.1g - Tom Almy
tom.almy@tek.com - 18 JUL 94
Generated with WebMaker