我正在学习Elm,并试图了解如何将字符串附加到列表中的所有项目,但是在每个条目的末尾而不是开头.很抱歉n00b问题,但我已经阅读了List.map,String(.appel,.join)周围的所有文档/示例,似乎无法找到答案.
例如
--create username list
usernames = ["Dave", "Simon", "Sally", "Joe"]
--create confirmExit function
confirmExit name = String.append " has left the room" name
--apply confirmExit function to all items in username list
List.map (\x -> confirmExit x) usernames
Run Code Online (Sandbox Code Playgroud)
给我:
["has leftDave","has leftSimon","has leftSally","has leftJoe"] : List String
Run Code Online (Sandbox Code Playgroud)
但是如何让它返回:
["Dave has left","Simon has left","Sally has left","Joe has left"] : List String
Run Code Online (Sandbox Code Playgroud)
是否有相应的.append添加到结尾而不是开头?请?!
| 归档时间: |
|
| 查看次数: |
350 次 |
| 最近记录: |