trizip haskell implementation
1 trizip :: [a] -> [b] -> [c] -> [(a,b,c)]
2 trizip a b c
3 | null a = []
4 | null b = []
5 | null c = []
6 trizip (x:xs) (y:ys) (z:zs) = (++) [(x,y,z)] (trizip xs ys zs)
daniel@daniel-mint ~/haskell $ ghci
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :l trizip.hs
[1 of 1] Compiling Main ( trizip.hs, interpreted )
Ok, modules loaded: Main.
*Main> trizip [1..100] ['a'..'z'] ['A'..'Z']
[(1,'a','A'),(2,'b','B'),(3,'c','C'),(4,'d','D'),(5,'e','E'),(6,'f','F'),(7,'g','G'),(8,'h','H'),(9,'i','I'),(10,'j','J'),(11,'k','K'),(12,'l','L'),(13,'m','M'),(14,'n','N'),(15,'o','O'),(16,'p','P'),(17,'q','Q'),(18,'r','R'),(19,'s','S'),(20,'t','T'),(21,'u','U'),(22,'v','V'),(23,'w','W'),(24,'x','X'),(25,'y','Y'),(26,'z','Z')]
*Main>
[11]+ Stopped ghci
trizip haskell implementation的更多相关文章
- Finding the Longest Palindromic Substring in Linear Time
Finding the Longest Palindromic Substring in Linear Time Finding the Longest Palindromic Substring i ...
- Haskell语言学习笔记(30)MonadCont, Cont, ContT
MonadCont 类型类 class Monad m => MonadCont m where callCC :: ((a -> m b) -> m a) -> m a in ...
- Haskell语言学习笔记(25)MonadState, State, StateT
MonadState 类型类 class Monad m => MonadState s m | m -> s where get :: m s get = state (\s -> ...
- Haskell语言学习笔记(24)MonadWriter, Writer, WriterT
MonadWriter 类型类 class (Monoid w, Monad m) => MonadWriter w m | m -> w where writer :: (a,w) -& ...
- Haskell语言学习笔记(23)MonadReader, Reader, ReaderT
MonadReader 类型类 class Monad m => MonadReader r m | m -> r where ask :: m r ask = reader id loc ...
- [Real World Haskell翻译]第22章 扩展示例:Web客户端编程
第22章 扩展示例:Web客户端编程 至此,您已经看到了如何与数据库交互,解析一些数据,以及处理错误.现在让我们更进了一步,引入Web客户端库的组合. 在本章,我们将开发一个真正的应用程序:一个播客下 ...
- Concepts & Implementation of PLs
http://perugini.cps.udayton.edu/teaching/courses/Spring2015/cps352/index.html#lecturenotes Programmi ...
- 怎样使用haskell编写应用程序
参考:http://stackoverflow.com/a/9153617 http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_prog ...
- 与项目欧拉速度比较:C vs Python与Erlang vs Haskell
我从问题#12 ProjectEuler作为编程练习,并比较我在C,Python,Erlang和Haskell中的实现(当然不是最优)实现.为了获得更高的执行时间,我搜索了第一个有1000个以上因子的 ...
随机推荐
- mysql中列转行
通过group_concat()函数来实现 select group_concat(name) from table group by type select group_concat(name se ...
- 报错: no such table:django_session解决方式
如果出现这个错误 “no such table:django_session” 这个错误跟Session的机制有关, 既然要从Web服务器端来记录用户信息, 那么一定要有存放用户session id对 ...
- spring boot 配置文件优先级
项目中可能存在多个配置文件,那么优先级定义如下: 1.同一目录,application.properties优先级高于application.yml 2.同一目录,config文件夹下的配置文件高于根 ...
- c#catch循环内捕获到异常继续循环
一,如果我们将异常而不影响循环,如下代码: using System; using System.Collections.Generic; using System.Linq; using Syste ...
- 三、SQL Server 对JSON的支持
一.SQL Server 对JSON的支持 一.实现效果 现在 我用数据库是sql2008 ,共计2万数据. 每一条数据里面的有一个为attribute字段是 json存储状态属性, 我怎么查看 ...
- 【LeetCode】智商题 brainteaser(共3题)
[292]Nim Game [319]Bulb Switcher [777]Swap Adjacent in LR String (2019年2月13日,谷歌tag) 给了两个字符串start 和en ...
- Opacity函数-transparentize()、 fade-out()函数
transparentize() 和 fade-out() 函数所起作用刚好与 opacify() 和 fade-in() 函数相反,让颜色更加的透明.这两个函数会让透明值做减法运算,当计算出来的结果 ...
- Jenkins ant打包部署
选择项目 自由风格
- [BZOJ1023][SHOI2008]cactus仙人掌图 DP
题目链接 套路就是先考虑一般的树上做法.求直径的dp的做法大家应该都会吧. 那么设\(dp[i]\)表示\(i\)的子树中的点到\(i\)的最大距离. 在dp的过程中 \[ ans=\max\{dp[ ...
- Web前端性能优化详解之CSS与JS加载
浏览器加载页面和渲染过程 加载过程 浏览器根据DNS 服务器得到域名的IP地坛 向这个 IP 的机器发送 HTTP请求 服务器收到,处理并返回 HTTP请求 浏览器得到返回内容 渲染过程 根据 HTM ...