From: Robert D. <rob...@us...> - 2007-01-08 04:57:49
|
Update of /cvsroot/maxima/maxima/doc/info In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25238/doc/info Modified Files: Lists.texi Log Message: New function sublist_indices, like sublist but it returns the indices of the items instead of the items themselves. - src/nset.lisp: Implementation of $sublist_indices - doc/info/Lists.texi: documentation - tests/rtestnset.mac: test cases Index: Lists.texi =================================================================== RCS file: /cvsroot/maxima/maxima/doc/info/Lists.texi,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- Lists.texi 25 Jun 2006 11:08:10 -0000 1.27 +++ Lists.texi 8 Jan 2007 04:57:46 -0000 1.28 @@ -432,6 +432,41 @@ @end deffn +@deffn {Function} sublist_indices (@var{L}, @var{P}) + +Returns the indices of the elements @code{x} of the list @var{L} for which +the predicate @code{maybe(@var{P}(x))} returns @code{true}; +this excludes @code{unknown} as well as @code{false}. +@var{P} may be the name of a function or a lambda expression. +@var{L} must be a literal list. + +Examples: +@c ===beg=== +@c sublist_indices ('[a, b, b, c, 1, 2, b, 3, b], lambda ([x], x='b)); +@c sublist_indices ('[a, b, b, c, 1, 2, b, 3, b], symbolp); +@c sublist_indices ([1 > 0, 1 < 0, 2 < 1, 2 > 1, 2 > 0], identity); +@c assume (x < -1); +@c map (maybe, [x > 0, x < 0, x < -2]); +@c sublist_indices ([x > 0, x < 0, x < -2], identity); +@c ===end=== + +@example +(%i1) sublist_indices ('[a, b, b, c, 1, 2, b, 3, b], lambda ([x], x='b)); +(%o1) [2, 3, 7, 9] +(%i2) sublist_indices ('[a, b, b, c, 1, 2, b, 3, b], symbolp); +(%o2) [1, 2, 3, 4, 7, 9] +(%i3) sublist_indices ([1 > 0, 1 < 0, 2 < 1, 2 > 1, 2 > 0], identity); +(%o3) [1, 4, 5] +(%i4) assume (x < -1); +(%o4) [x < - 1] +(%i5) map (maybe, [x > 0, x < 0, x < -2]); +(%o5) [false, true, unknown] +(%i6) sublist_indices ([x > 0, x < 0, x < -2], identity); +(%o6) [2] +@end example + +@end deffn + @deffn {Function} tenth (@var{expr}) Returns the 10'th item of expression or list @var{expr}. See @code{first} for more details. |