{"id":3520,"date":"2017-12-14T06:00:31","date_gmt":"2017-12-14T04:00:31","guid":{"rendered":"http:\/\/www.glc.us.es\/~jalonso\/exercitium\/?p=3520"},"modified":"2017-12-21T12:39:44","modified_gmt":"2017-12-21T10:39:44","slug":"aplicaciones-biyectivas","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/aplicaciones-biyectivas\/","title":{"rendered":"Aplicaciones biyectivas"},"content":{"rendered":"<p>Definir las funciones<\/p>\n<pre lang=\"text\">\n   biyectivas  :: (Ord a, Ord b) => [a] -> [b] -> [[(a,b)]]\n   nBiyectivas :: (Ord a, Ord b) => [a] -> [b] -> Integer\n<\/pre>\n<p>tales que<\/p>\n<ul>\n<li>(biyectivas xs ys) es el conjunto de las aplicaciones biyectivas del conjunto xs en el conjunto ys. Por ejemplo, <\/li>\n<\/ul>\n<pre lang=\"text\">\n     \u03bb> biyectivas [1,3] [2,4]\n     [[(1,2),(3,4)],[(1,4),(3,2)]]\n     \u03bb> biyectivas [1,3,5] [2,4,6]\n     [[(1,2),(3,4),(5,6)],[(1,4),(3,2),(5,6)],[(1,6),(3,4),(5,2)],\n      [(1,4),(3,6),(5,2)],[(1,6),(3,2),(5,4)],[(1,2),(3,6),(5,4)]]\n     \u03bb> biyectivas [1,3] [2,4,6]\n     []\n<\/pre>\n<ul>\n<li>(nBiyectivas xs ys) es el n\u00famero de aplicaciones biyectivas del conjunto xs en el conjunto ys. Por ejemplo,<\/li>\n<\/ul>\n<pre lang=\"text\">\n     nBiyectivas [1,3] [2,4]      ==  2\n     nBiyectivas [1,3,5] [2,4,6]  ==  6\n     \u03bb> nBiyectivas [1,3] [2,4,6] ==  0\n     length (show (nBiyectivas2 [1..2*10^4] [1..2*10^4]))  ==  77338\n<\/pre>\n<p><em>Nota<\/em>: En este ejercicio los conjuntos se representan mediante listas ordenadas de elementos distintos.<\/p>\n<h4>Soluciones<\/h4>\n<pre lang=\"haskell\">\nimport Data.List (genericLength, permutations)\n\n-- 1\u00aa definici\u00f3n de biyectivas\nbiyectivas :: (Ord a, Ord b) => [a] -> [b] -> [[(a,b)]]\nbiyectivas xs ys\n  | length xs == length ys = [zip xs zs | zs <- permutations ys]\n  | otherwise              = []\n\n-- 1\u00aa definici\u00f3n de nBiyectivas\nnBiyectivas :: (Ord a, Ord b) => [a] -> [b] -> Integer\nnBiyectivas xs ys\n  | length xs == length ys = genericLength (biyectivas xs ys)\n  | otherwise              = 0\n\n-- 2\u00aa definici\u00f3n de nBiyectivas\nnBiyectivas2 :: (Ord a, Ord b) => [a] -> [b] -> Integer\nnBiyectivas2 xs ys \n  | n == m    = product [1..n]\n  | otherwise = 0\n  where n = genericLength xs\n        m = genericLength ys\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Definir las funciones biyectivas :: (Ord a, Ord b) => [a] -> [b] -> [[(a,b)]] nBiyectivas :: (Ord a, Ord b) => [a] -> [b] -> Integer tales que (biyectivas xs ys) es el conjunto de las aplicaciones biyectivas del conjunto xs en el conjunto ys. Por ejemplo, \u03bb> biyectivas [1,3] [2,4] [[(1,2),(3,4)],[(1,4),(3,2)]] \u03bb> biyectivas&#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":[8,258,28,228,157],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/3520"}],"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=3520"}],"version-history":[{"count":2,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/3520\/revisions"}],"predecessor-version":[{"id":3550,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/3520\/revisions\/3550"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/media?parent=3520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/categories?post=3520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/tags?post=3520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}