{"id":485,"date":"2014-07-14T07:00:42","date_gmt":"2014-07-14T05:00:42","guid":{"rendered":"http:\/\/www.glc.us.es\/~jalonso\/exercitium\/?p=485"},"modified":"2015-05-01T09:04:38","modified_gmt":"2015-05-01T07:04:38","slug":"todas-tienen-par","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/todas-tienen-par\/","title":{"rendered":"Todas tienen par"},"content":{"rendered":"<pre lang=\"text\">\n-- Definir el predicado\n--    todasTienenPar :: [[Int]] -> Bool\n-- tal que (todasTienenPar xss) se verifica si cada elemento de\n-- la lista de listas xss contiene alg\u00fan n\u00famero par. Por ejemplo, \n--    todasTienenPar [[1,2],[3,4,5],[8]]  ==  True\n--    todasTienenPar [[1,2],[3,5]]        ==  False\n<\/pre>\n<h4>Soluciones<\/h4>\n<pre lang=\"haskell\">\n-- 1\u00aa definici\u00f3n (por comprensi\u00f3n)\n-- ===============================\n\ntodasTienenPar :: [[Int]] -> Bool\ntodasTienenPar xss = and [or [even x | x <- xs] | xs <- xss]\n\n-- 2\u00aa definici\u00f3n (por recursi\u00f3n)\n-- =============================\n\ntodasTienenPar2 :: [[Int]] -> Bool\ntodasTienenPar2 []       = True\ntodasTienenPar2 (xs:xss) = tienePar xs && todasTienenPar2 xss\n\n-- (tienePar xs) se verifica si xs contiene alg\u00fan n\u00famero par. \ntienePar  :: [Int] -> Bool\ntienePar []     = False\ntienePar (x:xs) = even x || tienePar xs\n\n-- 3\u00aa definici\u00f3n (por plegado)\n-- ===========================\n\ntodasTienenPar3 :: [[Int]] -> Bool\ntodasTienenPar3 = foldr ((&&) . tienePar3) True \n\n-- (tienePar3 xs) se verifica si xs contiene alg\u00fan n\u00famero par. \ntienePar3  :: [Int] -> Bool\ntienePar3 = foldr ((||) . even) False \n\n-- 4\u00aa definici\u00f3n (con cuantificadores)\n-- ===================================\n\ntodasTienenPar4 :: [[Int]] -> Bool\ntodasTienenPar4 = all (any even)\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8212; Definir el predicado &#8212; todasTienenPar :: [[Int]] -> Bool &#8212; tal que (todasTienenPar xss) se verifica si cada elemento de &#8212; la lista de listas xss contiene alg\u00fan n\u00famero par. Por ejemplo, &#8212; todasTienenPar [[1,2],[3,4,5],[8]] == True &#8212; todasTienenPar [[1,2],[3,5]] == False Soluciones &#8212; 1\u00aa definici\u00f3n (por comprensi\u00f3n) &#8212; =============================== todasTienenPar :: [[Int]] ->&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[5],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/485"}],"collection":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/comments?post=485"}],"version-history":[{"count":3,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/485\/revisions"}],"predecessor-version":[{"id":664,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/485\/revisions\/664"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/media?parent=485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/categories?post=485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/tags?post=485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}