-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve List.indexedMap example #1008
Comments
Personally, I prefer the first example because the relationship between the Perhaps we can still improve on the clarity on the first by not using the indexedMap (\i x -> (i, x)) ["Tom","Sue","Bob"] == [ (0,"Tom"), (1,"Sue"), (2,"Bob") ] But there is another benefit to the original, which is that it teaches both the |
That's a fair point. Perhaps using
and then pointing out that the anonymous function could be replaced by the |
|
I don't know for you but when I tried the example out of the box (elm 0.19), I get the following output: > List.indexedMap (,) ["Tom","Sue","Bob"]
-- PARSE ERROR ------------------------------------------------------------- elm
Something went wrong while parsing an expression (in parentheses) in
repl_value_1's definition.
4| List.indexedMap (,) ["Tom","Sue","Bob"]
^
I was expecting:
- an expression, like x or 42
- a closing paren
- a minus sign (-)
- an infix operator, like (+) or (==) So for me, the example is just wrong (or I miss something). Anyway, thank a lot for right examples here that help to undersetand this feature. |
Yeah, the |
# What is the change? * it adds another example that will hopefully be clearer to users. # Why the change? For me, the existing example was not altogether clear. (I am relatively new Elm user.) I did some Googling and found out that other users were facing the exact same issue: elm#1008 # The Solution: Add another example Hopefully it will be clearer.
The syntax changed to |
The current example for
List.indexedMap
isThe function being applied to the map is not immediately clear in this syntax. I would propose the following alternative example:
Perhaps this could be followed by an example in which the index parameter is inferred, as in the current example.
The text was updated successfully, but these errors were encountered: