Lists: Difference between revisions

From MemCP
Jump to navigation Jump to search
(Created page with "= Lists = The '''Lists''' module provides comprehensive list manipulation and processing functions for the SCM programming language. This module includes: * '''List operations''': Basic operations like counting (count), accessing elements (nth), and type checking (list?) * '''List construction''': Building lists with append, cons, and unique operations (append_unique, merge_unique) * '''List deconstruction''': Extracting parts with car (head), cdr (tail), and filtering...")
 
(Refresh MemCP documentation: accuracy, operational guidance, performance profile and maintained API reference)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<!-- Copyright (C) 2026 Carl-Philip Haensch -->
<!-- SPDX-License-Identifier: GPL-3.0-or-later -->
<span id="lists"></span>
= Lists =
= Lists =


The '''Lists''' module provides comprehensive list manipulation and processing functions for the SCM programming language. This module includes:
<!-- Generated from MemCP c42e19eba on 2026-08-27; do not edit manually. -->
<div class="mw-message-box mw-message-box-notice">Generated from MemCP commit <code>c42e19eba</code> on 27 August 2026. See [[Full SCM API documentation]].</div>
 
The '''Lists''' module provides the primary collection and code representation used by MemCP Scheme. It includes:
 
* construction with <code>list</code>, <code>cons</code>, append, merge, and zip operations;
* access through count, head/tail, indexed lookup, searching, and containment checks;
* functional transformation with map, filter, reduce, flattening, and deduplication;
* generation of ranges and computed sequences;
* ownership-aware internal variants used by optimized generated plans.
 
Lists are immutable at the language level. Quoted lists can represent data or delayed Scheme code; see [[Introduction to Scheme]] for quoting and evaluation rules.
 
== list ==
 
constructs a list from its arguments
 
'''Allowed number of parameters:''' 0–10000


* '''List operations''': Basic operations like counting (count), accessing elements (nth), and type checking (list?)
<span id="parameters"></span>
* '''List construction''': Building lists with append, cons, and unique operations (append_unique, merge_unique)
=== Parameters ===
* '''List deconstruction''': Extracting parts with car (head), cdr (tail), and filtering operations
* '''Functional programming''': Higher-order functions like map, filter, reduce, and produce for advanced list processing
* '''List utilities''': Searching (has?, contains?), merging, zipping, and flattening operations
* '''List generation''': Creating sequences and ranges with produce and produceN functions


These functions provide the essential tools for working with lists as the primary data structure in functional programming with SCM.
* '''items''' (<code>any</code>): items to put into the list ''(variadic)''


← Back to [[Full SCM API documentation]]
<span id="returns"></span>
=== Returns ===
 
* '''value''' (<code>list</code>)


== count ==
== count ==
Line 20: Line 40:
'''Allowed number of parameters:''' 1–1
'''Allowed number of parameters:''' 1–1


'''Parameters:'''
<span id="parameters-1"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): base list
* '''list''' (<code>list</code>): base list


'''Returns:''' <code>int</code>
<span id="returns-1"></span>
=== Returns ===
 
* '''value''' (<code>int</code>)


== nth ==
== nth ==
Line 31: Line 56:
'''Allowed number of parameters:''' 2–2
'''Allowed number of parameters:''' 2–2


'''Parameters:'''
<span id="parameters-2"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): base list
* '''list''' (<code>list</code>): base list
* '''index''' (<code>number</code>): index beginning from 0
* '''index''' (<code>number</code>): index beginning from 0


'''Returns:''' <code>any</code>
<span id="returns-2"></span>
=== Returns ===
 
* '''value''' (<code>any</code>)
 
== slice ==
 
extract a sublist from start (inclusive) to end (exclusive). (slice list start end) returns elements list[start..end).
 
'''Allowed number of parameters:''' 3–3
 
<span id="parameters-3"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): base list
* '''start''' (<code>number</code>): start index (inclusive)
* '''end''' (<code>number</code>): end index (exclusive)
 
<span id="returns-3"></span>
=== Returns ===
 
* '''value''' (<code>list</code>)
 
== reverse ==
 
returns a new list with elements in reversed order.
 
'''Allowed number of parameters:''' 1–1
 
<span id="parameters-4"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): list to reverse
 
<span id="returns-4"></span>
=== Returns ===
 
* '''value''' (<code>list</code>)


== append ==
== append ==
Line 41: Line 105:
appends items to a list and return the extended list. The original list stays unharmed.
appends items to a list and return the extended list. The original list stays unharmed.


'''Allowed number of parameters:''' 2–1000
'''Allowed number of parameters:''' 1–10000
 
<span id="parameters-5"></span>
=== Parameters ===


'''Parameters:'''
* '''list''' (<code>list</code>): base list
* '''list''' (<code>list</code>): base list
* '''item...''' (<code>any</code>): items to add
* '''item...''' (<code>any</code>): items to add ''(variadic)''
 
<span id="returns-5"></span>
=== Returns ===


'''Returns:''' <code>list</code>
* '''value''' (<code>list</code>)


== append_unique ==
== append_unique ==
Line 53: Line 122:
appends items to a list but only if they are new. The original list stays unharmed.
appends items to a list but only if they are new. The original list stays unharmed.


'''Allowed number of parameters:''' 2–1000
'''Allowed number of parameters:''' 1–10000
 
<span id="parameters-6"></span>
=== Parameters ===


'''Parameters:'''
* '''list''' (<code>list</code>): base list
* '''list''' (<code>list</code>): base list
* '''item...''' (<code>any</code>): items to add
* '''item...''' (<code>any</code>): items to add ''(variadic)''


'''Returns:''' <code>list</code>
<span id="returns-6"></span>
=== Returns ===
 
* '''value''' (<code>list</code>)


== cons ==
== cons ==
Line 67: Line 141:
'''Allowed number of parameters:''' 2–2
'''Allowed number of parameters:''' 2–2


'''Parameters:'''
<span id="parameters-7"></span>
=== Parameters ===
 
* '''car''' (<code>any</code>): new head element
* '''car''' (<code>any</code>): new head element
* '''cdr''' (<code>list</code>): tail that is appended after car
* '''cdr''' (<code>list</code>): tail that is appended after car


'''Returns:''' <code>list</code>
<span id="returns-7"></span>
=== Returns ===
 
* '''value''' (<code>list</code>)


== car ==
== car ==
Line 79: Line 158:
'''Allowed number of parameters:''' 1–1
'''Allowed number of parameters:''' 1–1


'''Parameters:'''
<span id="parameters-8"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): list
* '''list''' (<code>list</code>): list


'''Returns:''' <code>any</code>
<span id="returns-8"></span>
=== Returns ===
 
* '''value''' (<code>any</code>)


== cdr ==
== cdr ==


extracts the tail of a list. The tail of a list is a list with all items except the head.
extracts the tail of a list The tail of a list is a list with all items except the head.
 
'''Allowed number of parameters:''' 1–1
 
<span id="parameters-9"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): list
 
<span id="returns-9"></span>
=== Returns ===
 
* '''value''' (<code>list</code>)
 
== cadr ==
 
extracts the second element of a list. Equivalent to (car (cdr x)).


'''Allowed number of parameters:''' 1–1
'''Allowed number of parameters:''' 1–1


'''Parameters:'''
<span id="parameters-10"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): list
* '''list''' (<code>list</code>): list


'''Returns:''' <code>any</code>
<span id="returns-10"></span>
=== Returns ===
 
* '''value''' (<code>any</code>)


== zip ==
== zip ==
Line 99: Line 204:
swaps the dimension of a list of lists. If one parameter is given, it is a list of lists that is flattened. If multiple parameters are given, they are treated as the components that will be zipped into the sub list
swaps the dimension of a list of lists. If one parameter is given, it is a list of lists that is flattened. If multiple parameters are given, they are treated as the components that will be zipped into the sub list


'''Allowed number of parameters:''' 1–1000
'''Allowed number of parameters:''' 0–10000
 
<span id="parameters-11"></span>
=== Parameters ===
 
* '''list''' (<code>any</code>): list of lists of items ''(variadic)''


'''Parameters:'''
<span id="returns-11"></span>
* '''list''' (<code>list</code>): list of lists of items
=== Returns ===


'''Returns:''' <code>list</code>
* '''value''' (<code>list</code>)


== merge ==
== merge ==
Line 110: Line 220:
flattens a list of lists into a list containing all the subitems. If one parameter is given, it is a list of lists that is flattened. If multiple parameters are given, they are treated as lists that will be merged into one
flattens a list of lists into a list containing all the subitems. If one parameter is given, it is a list of lists that is flattened. If multiple parameters are given, they are treated as lists that will be merged into one


'''Allowed number of parameters:''' 1–1000
'''Allowed number of parameters:''' 0–10000
 
<span id="parameters-12"></span>
=== Parameters ===
 
* '''list''' (<code>any</code>): list of lists of items ''(variadic)''


'''Parameters:'''
<span id="returns-12"></span>
* '''list''' (<code>list</code>): list of lists of items
=== Returns ===


'''Returns:''' <code>list</code>
* '''value''' (<code>list</code>)


== merge_unique ==
== merge_unique ==
Line 121: Line 236:
flattens a list of lists into a list containing all the subitems. Duplicates are filtered out.
flattens a list of lists into a list containing all the subitems. Duplicates are filtered out.


'''Allowed number of parameters:''' 1–1000
'''Allowed number of parameters:''' 0–10000
 
<span id="parameters-13"></span>
=== Parameters ===


'''Parameters:'''
* '''list''' (<code>list</code>): list of lists of items ''(variadic)''
* '''list''' (<code>list</code>): list of lists of items


'''Returns:''' <code>list</code>
<span id="returns-13"></span>
=== Returns ===


* '''value''' (<code>list</code>)
<span id="has"></span>
== has? ==
== has? ==


Line 134: Line 255:
'''Allowed number of parameters:''' 2–2
'''Allowed number of parameters:''' 2–2


'''Parameters:'''
<span id="parameters-14"></span>
=== Parameters ===
 
* '''haystack''' (<code>list</code>): list to search in
* '''haystack''' (<code>list</code>): list to search in
* '''needle''' (<code>any</code>): item to search for
* '''needle''' (<code>any</code>): item to search for


'''Returns:''' <code>bool</code>
<span id="returns-14"></span>
=== Returns ===
 
* '''value''' (<code>bool</code>)


== filter ==
== filter ==
Line 146: Line 272:
'''Allowed number of parameters:''' 2–2
'''Allowed number of parameters:''' 2–2


'''Parameters:'''
<span id="parameters-15"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): list that has to be filtered
* '''list''' (<code>list</code>): list that has to be filtered
* '''condition''' (<code>func</code>): filter condition func(any)->bool
* '''condition''' (<code>func</code>): returns whether an item should be included
** '''Parameters'''
*** '''item''' (<code>any</code>): current list item
** '''Returns'''
*** '''included''' (<code>bool</code>): whether to include the item
 
<span id="returns-15"></span>
=== Returns ===
 
* '''value''' (<code>list</code>)
 
== find ==
 
returns the first list element that passes the condition function, or nil/default if none matches
 
'''Allowed number of parameters:''' 2–3
 
<span id="parameters-16"></span>
=== Parameters ===


'''Returns:''' <code>list</code>
* '''list''' (<code>list</code>): list to search
* '''condition''' (<code>func</code>): predicate applied until the first match
** '''Parameters'''
*** '''item''' (<code>any</code>): current list item
** '''Returns'''
*** '''matches''' (<code>bool</code>): whether the item matches
* '''default''' (<code>any</code>): optional default value if nothing matches ''(optional)''
 
<span id="returns-16"></span>
=== Returns ===
 
* '''value''' (<code>any</code>)


== map ==
== map ==
Line 158: Line 315:
'''Allowed number of parameters:''' 2–2
'''Allowed number of parameters:''' 2–2


'''Parameters:'''
<span id="parameters-17"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): list that has to be mapped
* '''list''' (<code>list</code>): list that has to be mapped
* '''map''' (<code>func</code>): map function func(any)->any that is applied to each item
* '''map''' (<code>func</code>): transforms each item
** '''Parameters'''
*** '''item''' (<code>any</code>): current list item
** '''Returns'''
*** '''mapped_item''' (<code>any</code>): transformed item
 
<span id="returns-17"></span>
=== Returns ===


'''Returns:''' <code>list</code>
* '''value''' (<code>list</code>)


== parallel_map ==
like map, but applies fn to each element in parallel using a worker pool limited to runtime.NumCPU()
'''Allowed number of parameters:''' 2–2
<span id="parameters-18"></span>
=== Parameters ===
* '''list''' (<code>list</code>): list to map over in parallel
* '''fn''' (<code>func</code>): function applied to each element
** '''Parameters'''
*** '''item''' (<code>any</code>)
** '''Returns'''
*** '''value''' (<code>any</code>)
<span id="returns-18"></span>
=== Returns ===
* '''value''' (<code>list</code>)
== parallel_map_mut ==
like parallel_map, but signals the optimizer that fn may have side effects
'''Allowed number of parameters:''' 2–2
<span id="parameters-19"></span>
=== Parameters ===
* '''list''' (<code>list</code>): list to map over in parallel
* '''fn''' (<code>func</code>): function with side effects applied to each element
** '''Parameters'''
*** '''item''' (<code>any</code>)
** '''Returns'''
*** '''value''' (<code>any</code>)
<span id="returns-19"></span>
=== Returns ===
* '''value''' (<code>list</code>)
<span id="mapindex"></span>
== mapIndex ==
== mapIndex ==


Line 170: Line 379:
'''Allowed number of parameters:''' 2–2
'''Allowed number of parameters:''' 2–2


'''Parameters:'''
<span id="parameters-20"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): list that has to be mapped
* '''list''' (<code>list</code>): list that has to be mapped
* '''map''' (<code>func</code>): map function func(i, any)->any that is applied to each item
* '''map''' (<code>func</code>): transforms each item with its index
** '''Parameters'''
*** '''index''' (<code>int</code>): zero-based item index
*** '''item''' (<code>any</code>): current list item
** '''Returns'''
*** '''mapped_item''' (<code>any</code>): transformed item


'''Returns:''' <code>list</code>
<span id="returns-20"></span>
=== Returns ===
 
* '''value''' (<code>list</code>)


== reduce ==
== reduce ==
Line 182: Line 401:
'''Allowed number of parameters:''' 2–3
'''Allowed number of parameters:''' 2–3


'''Parameters:'''
<span id="parameters-21"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): list that has to be reduced
* '''list''' (<code>list</code>): list that has to be reduced
* '''reduce''' (<code>func</code>): reduce function func(any any)->any where the first parameter is the accumulator, the second is a list item
* '''reduce''' (<code>func</code>): combines the accumulator with each list item
* '''neutral''' (<code>any</code>): (optional) initial value of the accumulator, defaults to nil
** '''Parameters'''
*** '''acc''' (<code>any</code>): current accumulator
*** '''item''' (<code>any</code>): current list item
** '''Returns'''
*** '''acc''' (<code>any</code>): next accumulator
* '''neutral''' (<code>any</code>): (optional) initial value of the accumulator, defaults to nil ''(optional)''
 
<span id="returns-21"></span>
=== Returns ===


'''Returns:''' <code>any</code>
* '''value''' (<code>any</code>)


== produce ==
== produce ==
Line 195: Line 424:
'''Allowed number of parameters:''' 3–3
'''Allowed number of parameters:''' 3–3


'''Parameters:'''
<span id="parameters-22"></span>
=== Parameters ===
 
* '''startstate''' (<code>any</code>): start state to begin with
* '''startstate''' (<code>any</code>): start state to begin with
* '''condition''' (<code>func</code>): func that returns true whether the state will be inserted into the result or the loop is stopped
* '''condition''' (<code>func</code>): func that returns true whether the state will be inserted into the result or the loop is stopped
** '''Parameters'''
*** '''state''' (<code>any</code>)
** '''Returns'''
*** '''value''' (<code>bool</code>)
* '''iterator''' (<code>func</code>): func that produces the next state
* '''iterator''' (<code>func</code>): func that produces the next state
** '''Parameters'''
*** '''state''' (<code>any</code>)
** '''Returns'''
*** '''value''' (<code>any</code>)


'''Returns:''' <code>list</code>
<span id="returns-22"></span>
=== Returns ===


* '''value''' (<code>list</code>)
<span id="producen"></span>
== produceN ==
== produceN ==


returns a list with numbers from 0..n-1
returns a list with numbers from 0..n-1, optionally mapped through a function
 
'''Allowed number of parameters:''' 1–2
 
<span id="parameters-23"></span>
=== Parameters ===
 
* '''n''' (<code>number</code>): number of elements to produce
* '''fn''' (<code>func</code>): (optional) map function applied to each index ''(optional)''
** '''Parameters'''
*** '''index''' (<code>int</code>)
** '''Returns'''
*** '''value''' (<code>any</code>)
 
<span id="returns-23"></span>
=== Returns ===
 
* '''value''' (<code>list</code>)
 
<span id="paralleln"></span>
== parallelN ==
 
returns a list with numbers from 0..n-1 mapped in parallel through a function
 
'''Allowed number of parameters:''' 2–2


'''Allowed number of parameters:''' 1–1
<span id="parameters-24"></span>
=== Parameters ===


'''Parameters:'''
* '''n''' (<code>number</code>): number of elements to produce
* '''n''' (<code>number</code>): number of elements to produce
* '''fn''' (<code>func</code>): map function applied to each index in parallel
** '''Parameters'''
*** '''index''' (<code>int</code>)
** '''Returns'''
*** '''value''' (<code>any</code>)
<span id="returns-24"></span>
=== Returns ===


'''Returns:''' <code>list</code>
* '''value''' (<code>list</code>)


<span id="list-1"></span>
== list? ==
== list? ==


Line 219: Line 495:
'''Allowed number of parameters:''' 1–1
'''Allowed number of parameters:''' 1–1


'''Parameters:'''
<span id="parameters-25"></span>
=== Parameters ===
 
* '''value''' (<code>any</code>): value to check
* '''value''' (<code>any</code>): value to check


'''Returns:''' <code>bool</code>
<span id="returns-25"></span>
=== Returns ===


* '''value''' (<code>bool</code>)
<span id="contains"></span>
== contains? ==
== contains? ==


Line 230: Line 512:
'''Allowed number of parameters:''' 2–2
'''Allowed number of parameters:''' 2–2


'''Parameters:'''
<span id="parameters-26"></span>
=== Parameters ===
 
* '''list''' (<code>list</code>): list to check
* '''list''' (<code>list</code>): list to check
* '''value''' (<code>any</code>): value to check
* '''value''' (<code>any</code>): value to check


'''Returns:''' <code>bool</code>
<span id="returns-26"></span>
=== Returns ===
 
* '''value''' (<code>bool</code>)
 
== sql_in ==
 
tests SQL IN-list membership and returns nil when NULL makes the result UNKNOWN
 
'''Allowed number of parameters:''' 2–2
 
<span id="parameters-27"></span>
=== Parameters ===
 
* '''values''' (<code>list</code>): SQL IN-list values
* '''value''' (<code>any</code>): value to find
 
<span id="returns-27"></span>
=== Returns ===
 
* '''value''' (<code>bool</code>)

Latest revision as of 11:59, 28 August 2026


Lists

Generated from MemCP commit c42e19eba on 27 August 2026. See Full SCM API documentation.

The Lists module provides the primary collection and code representation used by MemCP Scheme. It includes:

  • construction with list, cons, append, merge, and zip operations;
  • access through count, head/tail, indexed lookup, searching, and containment checks;
  • functional transformation with map, filter, reduce, flattening, and deduplication;
  • generation of ranges and computed sequences;
  • ownership-aware internal variants used by optimized generated plans.

Lists are immutable at the language level. Quoted lists can represent data or delayed Scheme code; see Introduction to Scheme for quoting and evaluation rules.

list

constructs a list from its arguments

Allowed number of parameters: 0–10000

Parameters

  • items (any): items to put into the list (variadic)

Returns

  • value (list)

count

counts the number of elements in the list

Allowed number of parameters: 1–1

Parameters

  • list (list): base list

Returns

  • value (int)

nth

get the nth item of a list

Allowed number of parameters: 2–2

Parameters

  • list (list): base list
  • index (number): index beginning from 0

Returns

  • value (any)

slice

extract a sublist from start (inclusive) to end (exclusive). (slice list start end) returns elements list[start..end).

Allowed number of parameters: 3–3

Parameters

  • list (list): base list
  • start (number): start index (inclusive)
  • end (number): end index (exclusive)

Returns

  • value (list)

reverse

returns a new list with elements in reversed order.

Allowed number of parameters: 1–1

Parameters

  • list (list): list to reverse

Returns

  • value (list)

append

appends items to a list and return the extended list. The original list stays unharmed.

Allowed number of parameters: 1–10000

Parameters

  • list (list): base list
  • item... (any): items to add (variadic)

Returns

  • value (list)

append_unique

appends items to a list but only if they are new. The original list stays unharmed.

Allowed number of parameters: 1–10000

Parameters

  • list (list): base list
  • item... (any): items to add (variadic)

Returns

  • value (list)

cons

constructs a list from a head and a tail list

Allowed number of parameters: 2–2

Parameters

  • car (any): new head element
  • cdr (list): tail that is appended after car

Returns

  • value (list)

car

extracts the head of a list

Allowed number of parameters: 1–1

Parameters

  • list (list): list

Returns

  • value (any)

cdr

extracts the tail of a list The tail of a list is a list with all items except the head.

Allowed number of parameters: 1–1

Parameters

  • list (list): list

Returns

  • value (list)

cadr

extracts the second element of a list. Equivalent to (car (cdr x)).

Allowed number of parameters: 1–1

Parameters

  • list (list): list

Returns

  • value (any)

zip

swaps the dimension of a list of lists. If one parameter is given, it is a list of lists that is flattened. If multiple parameters are given, they are treated as the components that will be zipped into the sub list

Allowed number of parameters: 0–10000

Parameters

  • list (any): list of lists of items (variadic)

Returns

  • value (list)

merge

flattens a list of lists into a list containing all the subitems. If one parameter is given, it is a list of lists that is flattened. If multiple parameters are given, they are treated as lists that will be merged into one

Allowed number of parameters: 0–10000

Parameters

  • list (any): list of lists of items (variadic)

Returns

  • value (list)

merge_unique

flattens a list of lists into a list containing all the subitems. Duplicates are filtered out.

Allowed number of parameters: 0–10000

Parameters

  • list (list): list of lists of items (variadic)

Returns

  • value (list)

has?

checks if a list has a certain item (equal?)

Allowed number of parameters: 2–2

Parameters

  • haystack (list): list to search in
  • needle (any): item to search for

Returns

  • value (bool)

filter

returns a list that only contains elements that pass the filter function

Allowed number of parameters: 2–2

Parameters

  • list (list): list that has to be filtered
  • condition (func): returns whether an item should be included
    • Parameters
      • item (any): current list item
    • Returns
      • included (bool): whether to include the item

Returns

  • value (list)

find

returns the first list element that passes the condition function, or nil/default if none matches

Allowed number of parameters: 2–3

Parameters

  • list (list): list to search
  • condition (func): predicate applied until the first match
    • Parameters
      • item (any): current list item
    • Returns
      • matches (bool): whether the item matches
  • default (any): optional default value if nothing matches (optional)

Returns

  • value (any)

map

returns a list that contains the results of a map function that is applied to the list

Allowed number of parameters: 2–2

Parameters

  • list (list): list that has to be mapped
  • map (func): transforms each item
    • Parameters
      • item (any): current list item
    • Returns
      • mapped_item (any): transformed item

Returns

  • value (list)

parallel_map

like map, but applies fn to each element in parallel using a worker pool limited to runtime.NumCPU()

Allowed number of parameters: 2–2

Parameters

  • list (list): list to map over in parallel
  • fn (func): function applied to each element
    • Parameters
      • item (any)
    • Returns
      • value (any)

Returns

  • value (list)

parallel_map_mut

like parallel_map, but signals the optimizer that fn may have side effects

Allowed number of parameters: 2–2

Parameters

  • list (list): list to map over in parallel
  • fn (func): function with side effects applied to each element
    • Parameters
      • item (any)
    • Returns
      • value (any)

Returns

  • value (list)

mapIndex

returns a list that contains the results of a map function that is applied to the list

Allowed number of parameters: 2–2

Parameters

  • list (list): list that has to be mapped
  • map (func): transforms each item with its index
    • Parameters
      • index (int): zero-based item index
      • item (any): current list item
    • Returns
      • mapped_item (any): transformed item

Returns

  • value (list)

reduce

returns a list that contains the result of a map function

Allowed number of parameters: 2–3

Parameters

  • list (list): list that has to be reduced
  • reduce (func): combines the accumulator with each list item
    • Parameters
      • acc (any): current accumulator
      • item (any): current list item
    • Returns
      • acc (any): next accumulator
  • neutral (any): (optional) initial value of the accumulator, defaults to nil (optional)

Returns

  • value (any)

produce

returns a list that contains produced items - it works like for(state = startstate, condition(state), state = iterator(state)) {yield state}

Allowed number of parameters: 3–3

Parameters

  • startstate (any): start state to begin with
  • condition (func): func that returns true whether the state will be inserted into the result or the loop is stopped
    • Parameters
      • state (any)
    • Returns
      • value (bool)
  • iterator (func): func that produces the next state
    • Parameters
      • state (any)
    • Returns
      • value (any)

Returns

  • value (list)

produceN

returns a list with numbers from 0..n-1, optionally mapped through a function

Allowed number of parameters: 1–2

Parameters

  • n (number): number of elements to produce
  • fn (func): (optional) map function applied to each index (optional)
    • Parameters
      • index (int)
    • Returns
      • value (any)

Returns

  • value (list)

parallelN

returns a list with numbers from 0..n-1 mapped in parallel through a function

Allowed number of parameters: 2–2

Parameters

  • n (number): number of elements to produce
  • fn (func): map function applied to each index in parallel
    • Parameters
      • index (int)
    • Returns
      • value (any)

Returns

  • value (list)

list?

checks if a value is a list

Allowed number of parameters: 1–1

Parameters

  • value (any): value to check

Returns

  • value (bool)

contains?

checks if a value is in a list; uses the equal?? operator

Allowed number of parameters: 2–2

Parameters

  • list (list): list to check
  • value (any): value to check

Returns

  • value (bool)

sql_in

tests SQL IN-list membership and returns nil when NULL makes the result UNKNOWN

Allowed number of parameters: 2–2

Parameters

  • values (list): SQL IN-list values
  • value (any): value to find

Returns

  • value (bool)