How do I combine two list in Haskell?

拜拜、爱过 提交于 2020-01-26 04:50:26

问题


I have the following two lines of code. I've tried merge and append but keep getting errors of type. The goal is to have one list that's BOTH a multiple of 5 or has exactly three factors.
For example : (function name) 100 -->

[4,5,9,10,15,20,25,30,35,40,45,49,50,55,60,65,70,75,80,85,90,95,100]

My two lines of code are :

mulitof5 x = [x | x <- [1..x], (x `mod` 5 == 0)]          
isPrimes n =  [n^2 | (n) <- [2..n-1], (all (\a -> mod n a /= 0) [2..n-1])]

Are merge and append the way to go?

Things I've tried:

mulitof5 x = [x | x <- [1..x], (x `mod` 5 == 0)| isprime n ]          
isPrimes n =  [n^2 | (n) <- [2..n-1], (all (\a -> mod n a /= 0) [2..n-1])]

fun n = merge (multiof 5, isPrime)

mulitof5 x = [x | x <- [1..x], (x `mod` 5 == 0)|  [n^2 | (n) <- [2..n-1], (all (\a -> mod n a /= 0) [2..n-1])] ]          

some of the things I've done

来源:https://stackoverflow.com/questions/59781958/how-do-i-combine-two-list-in-haskell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!