Chadtech / elm-vector / Vector46

A vector of length 46

Vector46


type alias Vector46 a =
Internal.Vector46 a

A vector that contains exactly 46 elements

Creation

fromList : List a -> Maybe ( List a, Vector46 a )

Turn a List a into a Vector46 a. If there are not enough items in the List a, then this function returns Nothing. The extra items in the input list, if there are any, is returned as the first element in the output tuple.

Vector3.fromList []
--> Nothing

Vector3.fromList [ 1 ]
--> Nothing

Vector3.fromList [ 5, 6, 7, 8 ]
--> Just ([ 8 ], Vector3.from3 5 6 7)

repeat : a -> Vector46 a

Make a Vector46 a filled with just one item repeated over and over again.

from46 : a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Vector46 a

Make a Vector46 a from 46 elements

fromListWithDefault : a -> List a -> ( List a, Vector46 a )

Turn a List a into a Vector46 a. If there are not enough items in the List a, then fill in the remaining spots with a default value. The extra items in the input list, if there are any, is returned as the first element in the output tuple.

Vector3.fromListWithDefault 1 []
--> ([] ,Vector3.from3 1 1 1)

Vector3.fromListWithDefault 2 [ 1 ]
--> ([], Vector3.from3 1 2 2)

Vector3.fromListWithDefault 2 [ 5, 6, 7, 8 ]
--> ([ 8 ], Vector3.from3 5 6 7)

initializeFromInt : (Basics.Int -> a) -> Vector46 a

Make a Vector46 a using a function that takes an Int, representing the index

initializeFromIndex : (Index -> a) -> Vector46 a

Make a Vector46 a using a function that takes an Index

Index


type Index
    = Index0
    | Index1
    | Index2
    | Index3
    | Index4
    | Index5
    | Index6
    | Index7
    | Index8
    | Index9
    | Index10
    | Index11
    | Index12
    | Index13
    | Index14
    | Index15
    | Index16
    | Index17
    | Index18
    | Index19
    | Index20
    | Index21
    | Index22
    | Index23
    | Index24
    | Index25
    | Index26
    | Index27
    | Index28
    | Index29
    | Index30
    | Index31
    | Index32
    | Index33
    | Index34
    | Index35
    | Index36
    | Index37
    | Index38
    | Index39
    | Index40
    | Index41
    | Index42
    | Index43
    | Index44
    | Index45

All the indices to a Vector46 a. There are exactly 46 of them. Its kind of like an Int except there is a finite amount of them.

get : Index -> Vector46 a -> a

Get the item at that Index in a Vector46 a

set : Index -> a -> Vector46 a -> Vector46 a

Set the item at a specific index in a Vector46 a

indices : Vector46 Index

A list of all the indices, from 0 to 45

indexToInt : Index -> Basics.Int

Turn the Index into an Int

intToIndex : Basics.Int -> Maybe Index

Try and turn an Int into an Index, returning Nothing if the Int is above the maximum index, or below the zero index, of this Vector46 a

    Vector5.intToIndex 4
    --> Just Vector5.Index4

    Vector3.intToIndex 4
    --> Nothing

nextIndex : Index -> Maybe Index

Given an index, get the next one. Unless its the last index in which case there is no next index (Nothing)

previousIndex : Index -> Maybe Index

Given an index, get the previous one. Unless its the 0 index in which case there is no previous index (Nothing)

Transform

map : (a -> b) -> Vector46 a -> Vector46 b

Apply a function to every element in a Vector46 a.

mapItem : Index -> (a -> a) -> Vector46 a -> Vector46 a

Transform just one particular item at a particular Index

indexedMap : (Index -> a -> b) -> Vector46 a -> Vector46 b

Apply a function on every element with its index as first argument

foldr : (a -> b -> b) -> b -> Vector46 a -> b

Reduce a Vector46 a from the right.

foldl : (a -> b -> b) -> b -> Vector46 a -> b

Reduce a Vector46 a from the left.

map2 : (a -> b -> c) -> Vector46 a -> Vector46 b -> Vector46 c

map3 : (a -> b -> c -> d) -> Vector46 a -> Vector46 b -> Vector46 c -> Vector46 d

map4 : (a -> b -> c -> d -> e) -> Vector46 a -> Vector46 b -> Vector46 c -> Vector46 d -> Vector46 e

map5 : (a -> b -> c -> d -> e -> f) -> Vector46 a -> Vector46 b -> Vector46 c -> Vector46 d -> Vector46 e -> Vector46 f

Lists

toList : Vector46 a -> List a

Convert a Vector46 a into a List a of length 46

toIndexedList : Vector46 a -> List ( Index, a )

Turn a Vector46 a elm into a list, where each element is paired with its Index

Methods

pop : Vector46 a -> ( Vector45.Internal.Vector45 a, a )

Separate a Vector46 a into its last element and everything else.

Vector4.pop (Vector4.from4 0 1 2 3)
--> (Vector3.from3 0 1 2, 3)

uncons : Vector46 a -> ( a, Vector45.Internal.Vector45 a )

Split a Vector46 a into its first element and the rest

Vector4.uncons (Vector4.from4 0 1 2 3)
--> (0, Vector3.from3 1 2 3)

push : a -> Vector46 a -> Vector47.Internal.Vector47 a

Add an element to the end of a Vector46 a, incrementing its size by 1

Vector4.push 4 (Vector4.from4 0 1 2 3)
--> Vector5.from5 0 1 2 3 4

cons : a -> Vector46 a -> Vector47.Internal.Vector47 a

Add an element to the front of a vector, incrementing the vector size by 1

Vector4.cons -1 (Vector4.from4 0 1 2 3)
--> Vector5.from5 -1 0 1 2 3

Util

length : Basics.Int

The length of this vector type, which is 46

reverse : Vector46 a -> Vector46 a

Reverse the order of the items in a Vector46 a

member : a -> Vector46 a -> Basics.Bool

See if a Vector46 a contains a value

group : List a -> ( List a, List (Vector46 a) )

Break a List a down into groups of Vector46 a. The output is a tuple, where the left side is a list of the remainder.

Vector3.group [ 1, 2, 3 ]
--> ([] , [ Vector3.from3 1 2 3 ])

Vector3.group [ 1, 2, 3, 4 ]
--> ([ 4 ] , [ Vector3.from3 1 2 3 ])

Vector3.group [ 1, 2, 3, 4, 5 ]
--> ([ 4, 5 ] , [ Vector3.from3 1 2 3 ])

Vector3.group [ 1, 2, 3, 4, 5, 6 ]
--> ([] , [ Vector3.from3 1 2 3, Vector3.from3 4 5 6 ])