I'll echo Duane twice here: 1) Coming mostly from Ruby, map definitely has a "only for looping constructs" feel to it, and 2) Joey's explanation was very helpful.
Thanks everyone! I'll go back to unlearning bad habits now. :P On Monday, July 25, 2016 at 2:19:29 PM UTC-5, Duane Johnson wrote: > > > On Mon, Jul 25, 2016 at 1:14 PM, Joey Eremondi <[email protected] > <javascript:>> wrote: > >> They let us re-use operations that we already have. You have a Maybe Int, >> and you want to double the int stored, if it's not null? Use "Maybe.map (\x >> -> x * 2)". This will double the Int, unless it's Nothing, in which case it >> gives you nothing back. >> >> You want to append a period to each string in your Dict? Then use >> 'Dict.map (\x -> x ++ ".") '. >> >> The map2, map3 etc. versions are just nice ways of extending this to >> things that take multiple arguments. If we have a Maybe Int and a Maybe >> Int, and we want to add them and get a result that's null if either one of >> them is, then map2 lets us do that. >> > > > This was very helpful, thank you. > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
