{"id":4873,"date":"2019-03-27T06:00:07","date_gmt":"2019-03-27T04:00:07","guid":{"rendered":"http:\/\/www.glc.us.es\/~jalonso\/exercitium\/?p=4873"},"modified":"2019-04-03T07:39:58","modified_gmt":"2019-04-03T05:39:58","slug":"matriz-girada-180-grados","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/matriz-girada-180-grados\/","title":{"rendered":"Matriz girada 180 grados"},"content":{"rendered":"<p>Definir la funci\u00f3n<\/p>\n<pre lang=\"text\"> \n   matrizGirada180 :: Matrix a -> Matrix a\n<\/pre>\n<p>tal que (matrizGirada180 p) es la matriz obtenida girando 180 grados la matriz p. Por  ejemplo,<\/p>\n<pre lang=\"text\"> \n   \u03bb> fromList 4 3 [1..]\n   (  1  2  3 )\n   (  4  5  6 )\n   (  7  8  9 )\n   ( 10 11 12 )\n\n   \u03bb> matrizGirada180 (fromList 4 3 [1..])\n   ( 12 11 10 )\n   (  9  8  7 )\n   (  6  5  4 )\n   (  3  2  1 )\n\n   \u03bb> fromList 3 4 [1..]\n   (  1  2  3  4 )\n   (  5  6  7  8 )\n   (  9 10 11 12 )\n\n   \u03bb> matrizGirada180 (fromList 3 4 [1..])\n   ( 12 11 10  9 )\n   (  8  7  6  5 )\n   (  4  3  2  1 )\n<\/pre>\n<h4>Soluciones<\/h4>\n<pre lang=\"haskell\">\nimport Data.Matrix ( Matrix\n                   , (!)\n                   , fromList\n                   , fromLists\n                   , matrix\n                   , ncols\n                   , nrows\n                   , toLists\n                   )\n\n-- 1\u00aa soluci\u00f3n\nmatrizGirada180 :: Matrix a -> Matrix a\nmatrizGirada180 p = matrix m n f\n  where m       = nrows p\n        n       = ncols p\n        f (i,j) = p!(m-i+1,n-j+1)\n\n-- 2\u00aa soluci\u00f3n\nmatrizGirada180b :: Matrix a -> Matrix a\nmatrizGirada180b p =\n  fromLists (reverse (map reverse (toLists p)))\n\n-- 3\u00aa soluci\u00f3n\nmatrizGirada180c :: Matrix a -> Matrix a\nmatrizGirada180c =\n  fromLists . reverse . map reverse . toLists\n<\/pre>\n<h4>Pensamiento<\/h4>\n<blockquote><p>\nBueno es recordar<br \/>\nlas palabras viejas<br \/>\nque han de volver a sonar.<\/p>\n<p>Antonio Machado\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Definir la funci\u00f3n matrizGirada180 :: Matrix a -> Matrix a tal que (matrizGirada180 p) es la matriz obtenida girando 180 grados la matriz p. Por ejemplo, \u03bb> fromList 4 3 [1..] ( 1 2 3 ) ( 4 5 6 ) ( 7 8 9 ) ( 10 11 12 ) \u03bb> matrizGirada180 (fromList 4&#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":[4],"tags":[96,10,42,97,99,98,11,32,389],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/4873"}],"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=4873"}],"version-history":[{"count":5,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/4873\/revisions"}],"predecessor-version":[{"id":4909,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/4873\/revisions\/4909"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/media?parent=4873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/categories?post=4873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/tags?post=4873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}