You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
As it stands, the types in this library are somewhat tedious to work with. Especially when applying
the same operation to multiple components. @fredcy mentioned on slack that conversion to List/Array is planned, but this still requires two conversions (to and from List/Array).
suggestion
Implement a pointwise map and map2 which are equivalent (in the Vec2 case) to
map: (Float->Float) ->Vec2->Vec2map f =
fromTuple <<(\(a, b)->(f a, f b))<< toTuple
map2: (Float->Float->Float) ->Vec2->Vec2->Vec2map2 f a b =let (left, right)=(toRecord a, toRecord b)in
fromTuple ( f left.x right.x, f left.y right.y )
edit: implementing map3 in terms of map2 isn't very practical
concrete use case:
-- maximal and minimal components of two vectors boundingBox a b =(map2 min a b, map2 max a b)
points of discussion
A logical extension would be to also introduce mapX, mapY, map...
pointwise is an alternative name to map2 that reads nicer (but is less consistent)
map2 is restricted to functions of type Float -> Float -> Float, where Float -> Float -> a would be more useful. Rather than adding functionality to Vector, a Tuple.Extra package could implement the various mapping functions.
The text was updated successfully, but these errors were encountered:
[2017-03-06: I copied this issue, created by @folkertdev, from https://github.com/elm-community/elm-linear-algebra/issues/18 per https://github.com//issues/7. -fredcy]
As it stands, the types in this library are somewhat tedious to work with. Especially when applying
the same operation to multiple components. @fredcy mentioned on slack that conversion to List/Array is planned, but this still requires two conversions (to and from List/Array).
suggestion
Implement a pointwise
map
andmap2
which are equivalent (in the Vec2 case) toedit: implementing
map3
in terms ofmap2
isn't very practicalconcrete use case:
points of discussion
mapX, mapY, map...
pointwise
is an alternative name tomap2
that reads nicer (but is less consistent)map2
is restricted to functions of typeFloat -> Float -> Float
, whereFloat -> Float -> a
would be more useful. Rather than adding functionality to Vector, aTuple.Extra
package could implement the various mapping functions.The text was updated successfully, but these errors were encountered: