I'm writing a simple code to add numbers in the list with the correct conditions into a new list. But I'm getting an error that one of the input is (Int, Bool) instead of Int, how did this happen? Here's the code I'm writing
module FilterList where
-- Definisi dan Spesifikasi
countIf :: [Int] -> (Int,Bool) -> [Int]
{-Mencari elemen yang memenuhi kriteria tertentu-}
isPos :: Int -> Bool
{-True jika positif-}
isNeg :: Int -> Bool
{-True jika negatif-}
isKabisat :: Int -> Bool
{-True jika berada pada tahun kabisat (dapat dibagi 4 atau 400 tetapi tidak bisa dibagi 100)-}
isEmpty :: [Int] -> Bool
{-True jika list kosong-}
-- Realisasi
isEmpty li = (length li) == 0
isPos a = a >= 0
isNeg a = a < 0
isKabisat a = (mod a 4) == 0 && ((mod a 100) /= 0 || (mod a 400) == 0)
countIf li func
| isEmpty li = []
| func (head li) = [] ++ [head li] ++ countIf (tail li) func
| otherwise = [] ++ countIf (tail li) func
Some stuff are in Indonesian but only in the comments so the general idea is still there.