A couple of well known tools carried over from the List module, and
others derived from it. Since the members of a list are Boxed, all of them
can be encapsulations of values of different types.
Finds a member in a boxed list, only if it could be transformed into a different value.
mapFind asString (Lst [ Integer 1, Str "b", Double 3.01 ]) == Just "b"
mapFind asBool (Lst [ Integer 1, Str "b", Double 3.01 ]) == NothingReturns only succesful values, resulting from the application of a given function.
filterMap asFloat (Lst [ Integer 1, Str "b", Double 3.01 ]) == [ 1, 3.01 ]
filterMap asBool (Lst [ Integer 1, Str "b", Double 3.01 ]) == []
filterMap asBool (Double 3.01) == []Adds an element to the front of a Boxed list. The encapsulated value
of the new member does not need to be of the same type as the rest.
cons (Integer 1) (Lst [ Str "b", Double 3.03 ]) == Lst [ Integer 1, Str "b", Double 3.03 ]
cons (Integer 1) (Lst []) == Lst [ Integer 1 ]
cons (Integer 1) (Str "d") == Lst [ Integer 1 ]Finds, inside a list, a 'Boxed' that passes a given test.
find isString (Lst [Integer 1, Str "b", Double 3.01]) == Just (Str "b")
find isTuple (Lst [Integer 1, Str "b", Double 3.01]) == Nothing
find isNull (Lst [Integer 1, Null, Double 3.01]) == Just NullApply a given function to a boxed list.
apply List.head (Lst [ Integer 1, Str "b", Double 3.03 ]) == Just (Integer 1)
apply List.tail (Lst [ Integer 1, Str "b", Double 3.03 ]) == Just [ Str "b", Double 3.03 ]
apply (List.member (Str "b")) (Lst [ Integer 1, Str "b", Double 3.03 ]) == True
apply (List.map asInt) (Lst [ Integer 1, Str "b", Double 3.03 ]) == [ Just 1, Nothing, Nothing ]
Returns the first member of a boxed list, only if it could be transformed into a different value.