Home
About
Policies
FAQ
Forums
Registration
Password Recovery

Sublist (MPI)

From Tapestries MUCK

(Difference between revisions)
Jump to: navigation, search
(provided a functional example.)
 
(2 intermediate revisions not shown)
Line 1: Line 1:
-
[[Category:MPI functions]]
+
[[Category:functions (MPI)]][[Category:List Handling Functions (MPI)]]
=sublist=
=sublist=
<mpi>{sublist:list,pos1}
<mpi>{sublist:list,pos1}
Line 11: Line 11:
The input list is assumed to be delimited by carriage returns (\r) unless the sep argument is given.
The input list is assumed to be delimited by carriage returns (\r) unless the sep argument is given.
 +
 +
Functional Example:
 +
<mpi>{with:command,
 +
{sublist:{mklist:{&arg}},1,1, },
 +
{with:arg1,
 +
{sublist:{mklist:{&arg}},2,-1, },
 +
dostuff}}
 +
</mpi>
 +
The above example would break {[[&arg]]} into new variables named {&command} for the first word and {&arg1} for the second word to the last.  Useful if your MPI if you want to simulate multipart commands in MPI. (i.e. cinfo #help, cinfo #help set, cinfo #fields, etc)

Latest revision as of 03:21, 25 April 2007

sublist

{sublist:list,pos1}
{sublist:list,pos1,pos2}
{sublist:list,pos1,pos2,sep}

Takes a list, and returns a subset of the list items within it.

The subset is all the list items between list item pos1, and list item pos2, inclusive.

If the pos2 argument is omitted, it assumes that pos2 is the same as pos1. If pos2 is less than pos1, then all the list items between pos2 and pos1 are returned, in reversed order. If pos1 or pos2 are negative, it counts that many list items back from the end of the list, so -1 is the last list item, and -5 would be the fifth from last list item.

The input list is assumed to be delimited by carriage returns (\r) unless the sep argument is given.

Functional Example:

{with:command,
{sublist:{mklist:{&arg}},1,1, },
{with:arg1,
{sublist:{mklist:{&arg}},2,-1, },
dostuff}}
 

The above example would break {&arg} into new variables named {&command} for the first word and {&arg1} for the second word to the last. Useful if your MPI if you want to simulate multipart commands in MPI. (i.e. cinfo #help, cinfo #help set, cinfo #fields, etc)

Personal tools
Namespaces
Variants
Actions
navagation
information
wiki
Toolbox