List Generic Operations

Basic operations

Module

UTCGP.listgeneric_basicModule

Basic Functions that apply to all lists

Exports : bundlelistgenericbasic: - identity_list - new_list - reverse_list

source

Functions

julia> identity_list([1,2,3,4])
4-element Vector{Int64}:
 1
 2
 3
 4
julia> new_list()
Any[]
julia> reverse_list([1,2])
2-element Vector{Int64}:
 2
 1

Subset functions

Module

UTCGP.listgeneric_subsetModule

Exports :

  • bundle_listgeneric_subset :
    • pick_from_exclusive_generic
    • pick_from_inclusive_generic
    • pick_until_exclusive_generic
    • pick_until_inclusive_generic
    • subset_list_of_tuples
    • subset_by_mask
    • subset_by_indices
source

Functions

UTCGP.listgeneric_subset.pick_from_inclusive_genericFunction
pick_from_inclusive_generic(
    list_gen::Vector{T},
    from_i::Int,
    args...,
)

Subsets a list from (inclusive) until the end of the list

In principle, from_i can also be negative, it will return the vector from the first index.

source
julia> pick_from_inclusive_generic([1,2,3,4], -1)
4-element Vector{Int64}:
 1
 2
 3
 4
julia> pick_from_inclusive_generic([1,2,3,4], 2)
3-element Vector{Int64}:
 2
 3
 4
julia> pick_from_inclusive_generic([1,2,3,4], 10)
Int64[]

Make Lists from elements

Module

UTCGP.listgeneric_makelistModule

Make vectors from elements of the same type

Exports : bundle_listgeneric_makelist:

  • make_list_from_one_element
  • make_list_from_two_elements
  • make_list_from_three_elements
source

Functions

julia> make_list_from_one_element(12344)
1-element Vector{Int64}:
 12344
julia> make_list_from_two_elements("ju","lia")
2-element Vector{String}:
 "ju"
 "lia"

Elements have to be of the same type (also applies for make_list_from_three_elements) :

julia> make_list_from_two_elements("juli",'a')
ERROR: MethodError: no method matching
julia> make_list_from_three_elements("ju", "l", "ia")
3-element Vector{String}:
 "ju"
 "l"
 "ia"

Concat Operation

Module

Functions

UTCGP.listgeneric_concat.concat_two_listsFunction
list_concat(list_a::Vector{T}, list_b::Vector{T}, args...)

Concats two lists, should be of the same type.

Although the types of the lists elements are not enforced.

T is a generic type.

source
julia> concat_two_lists([1,2], [3,4])
4-element Vector{Int64}:
 1
 2
 3
 4

But lists have to be of the same type:

julia> concat_two_lists([1,2], [3.0,4.0])
ERROR: MethodError: no method matching
[...]