Next: , Previous: , Up: srfi ilists procs   [Index]


2.40.6.4 Selectors

Function: value icar ipair
Function: value icdr ipair

These procedures return the contents of the icar and icdr field of their argument, respectively. Note that it is an error to apply them to the empty ilist.

(icar (iq a b c))       ⇒  a
(icdr (iq a b c))       ⇒  (b c)

(icar (iq (a) b c d))   ⇒  (a)
(icdr (iq (a) b c d))   ⇒  (b c d)

(icar (ipair 1 2))      ⇒  1
(icdr (ipair 1 2))      ⇒  2

(icar '())              error→  invalid argument
(icdr '())              error→  invalid argument
Function: value icaar ipair
Function: value icadr ipair
Function: value icdar ipair
Function: value icddr ipair

Compositions of icar and icdr.

Function: value icaaar ipair
Function: value icaadr ipair
Function: value icadar ipair
Function: value icaddr ipair
Function: value icdaar ipair
Function: value icdadr ipair
Function: value icddar ipair
Function: value icdddr ipair

Compositions of icar and icdr.

Function: value icaaaar ipair
Function: value icaaadr ipair
Function: value icaadar ipair
Function: value icaaddr ipair
Function: value icadaar ipair
Function: value icadadr ipair
Function: value icaddar ipair
Function: value icadddr ipair
Function: value icdaaar ipair
Function: value icdaadr ipair
Function: value icdadar ipair
Function: value icdaddr ipair
Function: value icddaar ipair
Function: value icddadr ipair
Function: value icdddar ipair
Function: value icddddr ipair

Compositions of icar and icdr.

Function: value ilist-ref ilist i

Return the i-th element of ilist. (This is the same as the icar of (idrop ilist i).) It is an error if ‘i >= n’, where n is the length of ilist.

(ilist-ref (iq a b c d) 2)      ⇒ c
Function: object ifirst ipair
Function: object isecond ipair
Function: object ithird ipair
Function: object ifourth ipair
Function: object ififth ipair
Function: object isixth ipair
Function: object iseventh ipair
Function: object ieighth ipair
Function: object ininth ipair
Function: object itenth ipair

Synonyms for icar, icadr, icaddr, …

(ithird '(a b c d e))           ⇒ c
Function: x y icar+icdr ipair

The fundamental ipair deconstructor:

(lambda (p) (values (icar p) (icdr p)))

This can, of course, be implemented more efficiently by a compiler.

Function: ilist itake x i
Function: object idrop x i
Function: object ilist-tail x i

itake returns the first i elements of ilist x. idrop returns all but the first i elements of ilist x. ilist-tail is either the same procedure as idrop or else a procedure with the same behavior.

(itake (iq a b c d e)  2)       ⇒ (a b)
(idrop (iq a b c d e)  2)       ⇒ (c d e)

x may be any value: a proper or dotted ilist:

(itake (ipair 1 (ipair 2 (ipair 3 'd)))         ⇒ (1 2)
(idrop (ipair 1 (ipair 2 (ipair 3 'd))) 2)      ⇒ (3 . d)
(itake (ipair 1 (ipair 2 (ipair 3 'd))) 3)      ⇒ (1 2 3)
(idrop (ipair 1 (ipair 2 (ipair 3 'd))) 3)      ⇒ d

For a legal i, itake and idrop partition the ilist in a manner which can be inverted with iappend:

(iappend (itake x i) (idrop x i))       ⇒ x

idrop is exactly equivalent to performing i icdr operations on x; the returned value shares a common tail with x.

Function: ilist itake-left x i
Function: object idrop-left x i

Aliases for itake and idrop.

NOTE These syntactic bindings are Vicare extensions.

Function: object itake-right dilist i
Function: object idrop-right dilist i

Return the last i elements of dilist. idrop-right returns all but the last i elements of dilist.

(itake-right (iq a b c d e) 2)  ⇒ (d e)
(idrop-right (iq a b c d e) 2)  ⇒ (a b c)

The returned ilist may share a common tail with the argument ilist.

dilist may be any ilist, either proper or dotted:

(itake-right (iq ipair 1 (ipair 2 (ipair 3 'd))) 2)     ⇒ (2 3 . d)
(idrop-right (ipair 1 (ipair 2 (ipair 3 'd))) 2)        ⇒ (1)
(itake-right (ipair 1 (ipair 2 (ipair 3 'd))) 0)        ⇒ d
(idrop-right (ipair 1 (ipair 2 (ipair 3 'd))) 0)        ⇒ (1 2 3)

For a legal i, itake-right and idrop-right partition the ilist in a manner which can be inverted with iappend:

(iappend (itake dilist i) (idrop dilist i)) ⇒ dilist

itake-right’s return value is guaranteed to share a common tail with dilist.

Function: ilist object isplit-at x i

Split the ilist x at index i, returning an ilist of the first i elements, and the remaining tail. It is equivalent to:

(values (itake x i) (idrop x i))
Function: object ilast ipair
Function: ipair last-ipair ipair

Return the last element of the non–empty, possibly dotted, ilist ipair. last-ipair returns the last ipair in the non–empty ilist pair.

(ilast (iq a b c))              ⇒ c
(last-ipair (iq a b c))         ⇒ (c)

Next: , Previous: , Up: srfi ilists procs   [Index]