Next: srfi ilists procs misc, Previous: srfi ilists procs predicates, Up: srfi ilists procs [Index]
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
Compositions of icar and icdr.
Compositions of icar and icdr.
Compositions of icar and icdr.
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
Synonyms for icar
, icadr
, icaddr
, …
(ithird '(a b c d e)) ⇒ c
The fundamental ipair deconstructor:
(lambda (p) (values (icar p) (icdr p)))
This can, of course, be implemented more efficiently by a compiler.
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.
Aliases for itake
and idrop
.
NOTE These syntactic bindings are Vicare extensions.
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.
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))
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: srfi ilists procs misc, Previous: srfi ilists procs predicates, Up: srfi ilists procs [Index]