This site is supported by donations to The OEIS Foundation.

Template:~List

From OeisWiki
Jump to: navigation, search

Core function for the {{list}} template.

Usage

Usage: do = create & from = b-file

The {{~List}} core function template extracts the second word (or number,) e.g. a(n) from a b-file line, from each of up to 257 lines, then creates a list from those items, separated with list_separator (default ,). The arguments are

  • do set to create (default is create)
  • from set to b-file (default is b-file)
  • input is a segment from a b-file (maximum of 257 lines of n a(n) pairs, separated with a single space, each line ending with a new line character)
  • word is zero-based index of word or number (default is 1, as a(n) is second number of a b-file line)
  • list_separator is character to use to separate the list items (default is ,)

Cf. {{List#Code}}.

Usage: do = get

The trailing list_separator (default ,) need to be removed by the {{list}} wrapper template.

The {{~List}} core function template may also be used to get the list item at index, with arguments

  • do set to get
  • list is a list (used in conjunction with do = get)
  • at is list item index (nonnegative from start of list, negative from end of list) (used in conjunction with do = get)
  • list_separator is character to use to separate the list items (default is ,)

Examples

Examples: do = create & from = b-file

Cf. {{List#Code}}.

Examples: do = get

Code Result
{{~List|get|2; 3; 5; 7; 11; 13; 17; 19; 23; 29|5|;}} 13
{{~List|get|2, 3, 5, 7, 11, 13, 17, 19, 23, 29}} 2
{{~List|get|2, 3, 5, 7, 11, 13, 17, 19, 23, 29|0}} 2
{{~List|get|2, 3, 5, 7, 11, 13, 17, 19, 23, 29|5}} 13
{{~List|get|2, 3, 5, 7, 11, 13, 17, 19, 23, 29|-11}}
{{~List|get|2, 3, 5, 7, 11, 13, 17, 19, 23, 29|-10}} 2
{{~List|get|2, 3, 5, 7, 11, 13, 17, 19, 23, 29|10}}
{{~List|get|2, 3, 5, 7, 11, 13, 17, 19, 23, 29|9}} 29
{{~List|get|2, 3, 5, 7, 11, 13, 17, 19, 23, 29|-1}} 29
{{~List|get|2, 3, 5, 7, 11, 13, 17, 19, 23, 29|-3}} 19