6.10 Operations on CL Types

Many of these are for compatibility, so you can shadow CL builtins with FSet operations of the same name without breaking existing code. Others are simply for convenience; you might find them useful on occasion.

Method: first (list)  ls

Compatibility method; forwards to cl:first. See first and last.

Method: first (sequence)  s

Returns (elt s 0).

Function: head ls

Returns (car ls). See head and tail.

Method: with-first (list)  ls x

Returns (cons x ls).

Method: less-first (list)  ls

Returns (cdr ls).

Function: tail ls

Returns (cdr ls). See head and tail.

Method: last (list)  ls

Returns the last element of ls (not its last cons!). See first and last.

Method: last (sequence)  s

Returns (elt s (1- (length s))).

Function: lastcons ls

Returns (cl:last ls), that is, the last cons in ls. See Divergences from Common Lisp.

Method: with-last (list)  ls x

Returns (append ls (list x)).

Method: less-last (list)  ls

Returns (butlast ls).

Method: contains? (list)  ls x

Returns (member x ls :test #'equal?).

Method: subseq (sequence)  s start &optional end

Compatibility method; forwards to cl:subseq.

Method: reverse (sequence)  s

Compatibility method; forwards to cl:reverse.

Method: concat (list)  ls &rest more-lists

Returns the concatenation of ls with each of more-lists in succession. more-lists can contain anything that can be converted to a list, which includes FSet collections and CL sequences.

Method: partition (function list)  pred ls
Method: partition (symbol list)  pred ls

Returns, as two values, ls filtered by pred, and ls filtered by the complement of pred.

Method: filter (t sequence)  fn s

A synonym for cl:remove-if-not.

Method: image (function list)  fn ls
Method: image (symbol list)  fn ls
Method: image (map list)  fn ls

Returns a list containing the values of fn applied to each element of ls, in order. fn must be a function, an fbound symbol, or a map.

Method: image (function vector)  fn v
Method: image (symbol vector)  fn v
Method: image (map vector)  fn v

Returns a simple-vector containing the values of fn applied to each element of v, in order. fn must be a function, an fbound symbol, or a map.

Method: reduce (t sequence)  fn s &key key initial-value start end from-end

Compatibility method; forwards to cl:reduce.

Method: find (t sequence)  item s &key key test test-not start end from-end
Method: find-if (t sequence)  pred s &key key start end from-end
Method: find-if-not (t sequence)  pred s &key key start end from-end
Method: count (t sequence)  item s &key key test test-not start end from-end
Method: count-if (t sequence)  pred s &key key start end from-end
Method: count-if-not (t sequence)  pred s &key key start end from-end
Method: position (t sequence)  item s &key key test test-not start end from-end
Method: position-if (t sequence)  pred s &key key start end from-end
Method: position-if-not (t sequence)  pred s &key key start end from-end
Method: remove (t sequence)  item s &key key test test-not start end from-end count
Method: remove-if (t sequence)  pred s &key key start end from-end count
Method: remove-if-not (t sequence)  pred s &key key start end from-end count
Method: substitute (t sequence)  newitem olditem s &key key test test-not start end from-end count
Method: substitute-if (t sequence)  newitem pred s &key key start end from-end count
Method: substitute-if-not (t sequence)  newitem pred s &key key start end from-end count
Method: search (sequence sequence)  sequence-1 sequence-2 &key test key from-end start1 start2 end1 end2
Method: mismatch (sequence sequence)  sequence-1 sequence-2 &key test key from-end start1 start2 end1 end2

Compatibility methods; they all forward to the CL builtin of the same name.

Method: iterator (sequence)  s
Method: iterator (list)  s
Method: iterator (vector)  s
Method: iterator (string)  s

Returns a stateful iterator over s, a list, vector, string, or other sequence (if the implementation has other sequence types).

Method: fun-iterator (sequence)  s &key from-end?
Method: fun-iterator (list)  s &key from-end?
Method: fun-iterator (vector)  s &key from-end?
Method: fun-iterator (string)  s &key from-end?

Returns a functional iterator over s, a list, vector, string, or other sequence (if the implementation has other sequence types). If from-end? is true, the iteration will be in reverse order.

Method: sort (sequence t)  s pred &key key
Method: stable-sort (sequence t)  s pred &key key

Compatibility methods; forward to cl:sort or cl:stable-sort respectively. Copies s first, however, so unlike the CL builtins, these never mutate their operands.

Method: union (list list)  l1 l2 &key test test-not
Method: intersection (list list)  l1 l2 &key test test-not
Method: set-difference (list list)  l1 l2 &key test test-not

Compatibility methods; forward to the CL builtin of the same name.

Method: compose (function function)  f1 f2
Method: compose (function symbol)  f1 f2
Method: compose (symbol function)  f1 f2
Method: compose (symbol symbol)  f1 f2

Returns the composition of f1 with f2. multiple-value-call is used to pass all values returned by f1 as arguments to f2.