纯属为了练习haskell, 竟然贴代码都没办法高亮。

challenges/fp-update-list

Update the values of a list with their absolute values. The input and output portions will be handled automatically during grading. You only need to write a function with the recommended method signature.

Input Format 
There are N integers, each on a new line. These are the N elements of the input array.

Output Format 
N integers each on a new line; these are the absolute values of the input list, in that order.

Sample Input

2
-4
3
-1
23
-4
-54

Sample Output

2
4
3
1
23
4
54

Accpeted Code:

 -- Enter your code here. Read input from STDIN. Print output to STDOUT

 f arr = [if x >= 0 then x else -x | x <- arr] -- Complete this function here

 -- This section handles the Input/Output and can be used as it is. Do not modify it.
main = do
inputdata <- getContents
mapM_ putStrLn $ map show $ f $ map (read :: String -> Int) $ lines inputdata

最新文章

  1. ArcGIS10.2.2 Desktop直接连接数据库的具体步骤
  2. gcc 4.8.3 install centos
  3. POJ-2886 Who Gets the Most Candies?(线段树+模拟)
  4. C# Winform开发框架模块图(平台核心模块+示例模块)
  5. MVC应用程序与单选列表
  6. 1号店Interview小结
  7. Drupal设置首页默认内容
  8. CAP理论与MongoDB一致性、可用性的一些思考
  9. [转载]GIF、JPEG 和 PNG的区别在哪里?
  10. Mysql主从复制架构实战
  11. C语言编对双精度数保留一位小数
  12. Java笔记(day11)
  13. jenkins主要目录用途
  14. linux系统下安装redis以及java调用redis
  15. Spherical Hashing,球哈希
  16. ubuntu16.04安装 lrzsz
  17. Django框架(三) 复习总结与路由控制
  18. [Vani有约会]雨天的尾巴——树上差分+动态开点线段树合并
  19. java类的初始化的默认值
  20. linux ln 命令,相当于windows快捷方式

热门文章

  1. 双系统可以进入Windows但进入Ubuntu时无法进入系统引导,只有左上角光标闪
  2. c语言一个例子对比php学习随记
  3. Installing Node.js and Express on Ubuntu
  4. PAT甲级——A1028 List Sorting
  5. CF538G (套路题)
  6. php 5.3 iis php_memcache 安装不上
  7. useradd -M -s /sbin/nologin mysql -g mysql 报错 Creating mailbox file
  8. cmd命令调用powershell脚本方法
  9. linux下文件操作之cp和mv
  10. 图像通道、Scalar、分离、合成通道