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
Today we can map list to array, iterate array, etc
Would be awesome to treat tuple the same way
I understand it might contain different types in a tuple, so perhaps we can invent a tuple that only contains the same type for example (int * int), and we add these nice functionality for us to do (5,10) |> Tuple.Map (fun number -> number.ToString())
For people who walk this path after us, they can create specializations for tuple of primitive types to be struct, optimize etc
Tuple tends to contain a couple elements as they had to be written out in code by hand usually and it's a syntax sugar to everyday f# users so might as well make it more useful and cost nothing to use
But for now adding new functions to tuple and making the language treat tuple with the same types and different types differently, is the topic (that means (5,5) and (5,"5") is treated as two different types by the language, allowing tuple mapping functions be able to be used on the former)
We should also add a method called normalize, (5,"5") |> Tuple.Normalize (fun a,b -> a, int(b)) which infers the types contained in tuple and allow us to convert it to a tuple that only contains 1 type
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Today we can map list to array, iterate array, etc
Would be awesome to treat tuple the same way
I understand it might contain different types in a tuple, so perhaps we can invent a tuple that only contains the same type for example (int * int), and we add these nice functionality for us to do
(5,10) |> Tuple.Map (fun number -> number.ToString())
For people who walk this path after us, they can create specializations for tuple of primitive types to be struct, optimize etc
Tuple tends to contain a couple elements as they had to be written out in code by hand usually and it's a syntax sugar to everyday f# users so might as well make it more useful and cost nothing to use
But for now adding new functions to tuple and making the language treat tuple with the same types and different types differently, is the topic (that means
(5,5)
and(5,"5")
is treated as two different types by the language, allowing tuple mapping functions be able to be used on the former)We should also add a method called normalize,
(5,"5") |> Tuple.Normalize (fun a,b -> a, int(b))
which infers the types contained in tuple and allow us to convert it to a tuple that only contains 1 typeBeta Was this translation helpful? Give feedback.
All reactions