hackerrank--- challenges/fp-update-list
2024-10-08 02:28:34
纯属为了练习haskell, 竟然贴代码都没办法高亮。
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
最新文章
- ArcGIS10.2.2 Desktop直接连接数据库的具体步骤
- gcc 4.8.3 install centos
- POJ-2886 Who Gets the Most Candies?(线段树+模拟)
- C# Winform开发框架模块图(平台核心模块+示例模块)
- MVC应用程序与单选列表
- 1号店Interview小结
- Drupal设置首页默认内容
- CAP理论与MongoDB一致性、可用性的一些思考
- [转载]GIF、JPEG 和 PNG的区别在哪里?
- Mysql主从复制架构实战
- C语言编对双精度数保留一位小数
- Java笔记(day11)
- jenkins主要目录用途
- linux系统下安装redis以及java调用redis
- Spherical Hashing,球哈希
- ubuntu16.04安装 lrzsz
- Django框架(三) 复习总结与路由控制
- [Vani有约会]雨天的尾巴——树上差分+动态开点线段树合并
- java类的初始化的默认值
- linux ln 命令,相当于windows快捷方式
热门文章
- 双系统可以进入Windows但进入Ubuntu时无法进入系统引导,只有左上角光标闪
- c语言一个例子对比php学习随记
- Installing Node.js and Express on Ubuntu
- PAT甲级——A1028 List Sorting
- CF538G (套路题)
- php 5.3 iis php_memcache 安装不上
- useradd -M -s /sbin/nologin mysql -g mysql 报错 Creating mailbox file
- cmd命令调用powershell脚本方法
- linux下文件操作之cp和mv
- 图像通道、Scalar、分离、合成通道