<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="es">
	<id>https://www.glc.us.es/WIKIS/I1M2021G2/index.php?action=history&amp;feed=atom&amp;title=Relaci%C3%B3n_9_Sol</id>
	<title>Relación 9 Sol - Historial de revisiones</title>
	<link rel="self" type="application/atom+xml" href="https://www.glc.us.es/WIKIS/I1M2021G2/index.php?action=history&amp;feed=atom&amp;title=Relaci%C3%B3n_9_Sol"/>
	<link rel="alternate" type="text/html" href="https://www.glc.us.es/WIKIS/I1M2021G2/index.php?title=Relaci%C3%B3n_9_Sol&amp;action=history"/>
	<updated>2026-07-19T12:44:35Z</updated>
	<subtitle>Historial de revisiones de esta página en el wiki</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>https://www.glc.us.es/WIKIS/I1M2021G2/index.php?title=Relaci%C3%B3n_9_Sol&amp;diff=532&amp;oldid=prev</id>
		<title>Mdelamor en 15:31 10 dic 2021</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/WIKIS/I1M2021G2/index.php?title=Relaci%C3%B3n_9_Sol&amp;diff=532&amp;oldid=prev"/>
		<updated>2021-12-10T15:31:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;es&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Revisión anterior&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revisión del 15:31 10 dic 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Línea 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línea 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;#039;haskell&amp;#039;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;#039;haskell&amp;#039;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-- PD Practica 5.2 Solución&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- Funciones de orden superior y definiciones por plegados (&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;extra&lt;/ins&gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- Funciones de orden superior y definiciones por plegados (&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;II&lt;/del&gt;)&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- Departamento de Ciencias de la Computación e Inteligencia Artificial&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- Departamento de Ciencias de la Computación e Inteligencia Artificial&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- Universidad de Sevilla&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- Universidad de Sevilla&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mdelamor</name></author>
	</entry>
	<entry>
		<id>https://www.glc.us.es/WIKIS/I1M2021G2/index.php?title=Relaci%C3%B3n_9_Sol&amp;diff=531&amp;oldid=prev</id>
		<title>Mdelamor: Protegió «Relación 9 Sol» ([Editar=Solo administradores] (indefinido) [Trasladar=Solo administradores] (indefinido))</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/WIKIS/I1M2021G2/index.php?title=Relaci%C3%B3n_9_Sol&amp;diff=531&amp;oldid=prev"/>
		<updated>2021-12-10T15:31:12Z</updated>

		<summary type="html">&lt;p&gt;Protegió «&lt;a href=&quot;/WIKIS/I1M2021G2/index.php/Relaci%C3%B3n_9_Sol&quot; title=&quot;Relación 9 Sol&quot;&gt;Relación 9 Sol&lt;/a&gt;» ([Editar=Solo administradores] (indefinido) [Trasladar=Solo administradores] (indefinido))&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;es&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Revisión anterior&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revisión del 15:31 10 dic 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;es&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(Sin diferencias)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Mdelamor</name></author>
	</entry>
	<entry>
		<id>https://www.glc.us.es/WIKIS/I1M2021G2/index.php?title=Relaci%C3%B3n_9_Sol&amp;diff=530&amp;oldid=prev</id>
		<title>Mdelamor en 15:30 10 dic 2021</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/WIKIS/I1M2021G2/index.php?title=Relaci%C3%B3n_9_Sol&amp;diff=530&amp;oldid=prev"/>
		<updated>2021-12-10T15:30:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;es&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Revisión anterior&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revisión del 15:30 10 dic 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l294&quot;&gt;Línea 294:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línea 294:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;head_permanente :: Ord a =&amp;gt; [a] -&amp;gt; Bool&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;head_permanente :: Ord a =&amp;gt; [a] -&amp;gt; Bool&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;head_permanente (y:[]) = True&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;head_permanente (y:[]) = True&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;head_permanente (y:ys) = (maximum ys &amp;lt; y)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;head_permanente (y:ys) = (maximum ys &amp;lt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;= &lt;/ins&gt;y)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- 1) por comprensión,&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- 1) por comprensión,&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mdelamor</name></author>
	</entry>
	<entry>
		<id>https://www.glc.us.es/WIKIS/I1M2021G2/index.php?title=Relaci%C3%B3n_9_Sol&amp;diff=529&amp;oldid=prev</id>
		<title>Mdelamor: Página creada con «&lt;source lang=&#039;haskell&#039;&gt; -- PD Practica 5.2 Solución -- Funciones de orden superior y definiciones por plegados (II) -- Departamento de Ciencias de la Computación e Inteli…»</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/WIKIS/I1M2021G2/index.php?title=Relaci%C3%B3n_9_Sol&amp;diff=529&amp;oldid=prev"/>
		<updated>2021-12-10T15:29:50Z</updated>

		<summary type="html">&lt;p&gt;Página creada con «&amp;lt;source lang=&amp;#039;haskell&amp;#039;&amp;gt; -- PD Practica 5.2 Solución -- Funciones de orden superior y definiciones por plegados (II) -- Departamento de Ciencias de la Computación e Inteli…»&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Página nueva&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;source lang=&amp;#039;haskell&amp;#039;&amp;gt;&lt;br /&gt;
-- PD Practica 5.2 Solución&lt;br /&gt;
-- Funciones de orden superior y definiciones por plegados (II)&lt;br /&gt;
-- Departamento de Ciencias de la Computación e Inteligencia Artificial&lt;br /&gt;
-- Universidad de Sevilla&lt;br /&gt;
-- ============================================================================&lt;br /&gt;
-- ============================================================================&lt;br /&gt;
-- Librerías auxiliares&lt;br /&gt;
-- ============================================================================&lt;br /&gt;
import Data.Char&lt;br /&gt;
import Data.List&lt;br /&gt;
-- cabal install primes&lt;br /&gt;
import Data.Numbers.Primes&lt;br /&gt;
import Test.QuickCheck&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
-- Ejercicio 1. Se considera la función&lt;br /&gt;
--      resultadoPos :: (a -&amp;gt; Integer) -&amp;gt; [a] -&amp;gt; [a]&lt;br /&gt;
-- tal que (resultadoPos f xs) es la lista de los elementos de la lista&lt;br /&gt;
-- xs tales que el valor de la función f sobre ellos es positivo. Por ejemplo,&lt;br /&gt;
--   resultadoPos head [[-1,2],[-9,4],[2,3]]       ==  [[2,3]]&lt;br /&gt;
--   resultadoPos sum [[1,2],[9],[-8,3],[],[3,5]]  ==  [[1,2],[9],[3,5]]&lt;br /&gt;
--&lt;br /&gt;
-- Define esta función&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
-- 2) por orden superior (map, filter, ...),&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
-- -----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
resultadoPosC :: (a -&amp;gt; Integer) -&amp;gt; [a] -&amp;gt; [a]&lt;br /&gt;
resultadoPosC f xs = [x | x &amp;lt;- xs, f x &amp;gt; 0]&lt;br /&gt;
&lt;br /&gt;
-- 2) por orden superior (map, filter, ...),&lt;br /&gt;
resultadoPosS :: (a -&amp;gt; Integer) -&amp;gt; [a] -&amp;gt; [a]&lt;br /&gt;
resultadoPosS f xs = filter (\x -&amp;gt; f x &amp;gt; 0) xs&lt;br /&gt;
&lt;br /&gt;
resultadoPosS&amp;#039; f xs = filter lp (zip (map f xs) xs)&lt;br /&gt;
    where lp (a, b) = a &amp;gt; 0&lt;br /&gt;
&lt;br /&gt;
resultadoPosS&amp;#039;&amp;#039; :: (a -&amp;gt; Integer) -&amp;gt; [a] -&amp;gt; [a]          &lt;br /&gt;
resultadoPosS&amp;#039;&amp;#039; f = filter ((&amp;gt;0).f)&lt;br /&gt;
&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
resultadoPosR :: (a -&amp;gt; Integer) -&amp;gt; [a] -&amp;gt; [a]&lt;br /&gt;
resultadoPosR _ [] = []&lt;br /&gt;
resultadoPosR f (x:xs) &lt;br /&gt;
    | f x &amp;gt; 0   = x: resultadoPosR f xs&lt;br /&gt;
    | otherwise = resultadoPosR f xs&lt;br /&gt;
&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
resultadoPosP :: (a -&amp;gt; Integer) -&amp;gt; [a] -&amp;gt; [a]&lt;br /&gt;
resultadoPosP f = foldr (\x acc -&amp;gt; if f x &amp;gt; 0 then x:acc else acc) []&lt;br /&gt;
&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
-- Ejercicio 2. Se considera la función&lt;br /&gt;
--     intercala :: Int -&amp;gt; [Int] -&amp;gt; [Int]&lt;br /&gt;
-- tal que (intercala y xs) es la lista que resulta de intercalar el elemento&lt;br /&gt;
-- y delante de todos los elementos de la lista xs que sean menores que y.&lt;br /&gt;
-- Por ejemplo,&lt;br /&gt;
--   intercala 5 [1,2,6,3,7,9]  ==  [5,1,5,2,6,5,3,7,9]&lt;br /&gt;
--   intercala 5 [6,7,9,8]      ==  [6,7,9,8]&lt;br /&gt;
--&lt;br /&gt;
-- Define esta función&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
intercalaC :: Int -&amp;gt; [Int] -&amp;gt; [Int]&lt;br /&gt;
intercalaC y xs =  [x | xs &amp;lt;- xss, x &amp;lt;- xs]&lt;br /&gt;
    where xss = [if x &amp;lt; y then [y, x] else [x] | x &amp;lt;- xs]&lt;br /&gt;
&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)&lt;br /&gt;
intercalaS :: Int -&amp;gt; [Int] -&amp;gt; [Int]&lt;br /&gt;
intercalaS y xs = concat (map (\x -&amp;gt; if x &amp;lt; y then [y, x] else [x]) xs)&lt;br /&gt;
&lt;br /&gt;
intercalaS&amp;#039; y xs = concatMap (\ x -&amp;gt; if y &amp;gt; x then [y, x] else [x]) xs&lt;br /&gt;
&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
intercalaR :: Int -&amp;gt; [Int] -&amp;gt; [Int]&lt;br /&gt;
intercalaR _ [] = []&lt;br /&gt;
intercalaR y (x:xs)&lt;br /&gt;
    | x &amp;lt; y         = y:x:intercalaR y xs&lt;br /&gt;
    | otherwise     = x:intercalaR y xs&lt;br /&gt;
    &lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
intercalaP :: Int -&amp;gt; [Int] -&amp;gt; [Int]&lt;br /&gt;
intercalaP y = foldr (\x acc -&amp;gt; if x &amp;lt; y then y:x:acc else x:acc) []&lt;br /&gt;
&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
-- Ejercicio 3. Se considera la función&lt;br /&gt;
--    dec2ent :: [Integer] -&amp;gt; Integer&lt;br /&gt;
-- tal que (dec2ent xs) es el número entero cuyas cifras ordenadas son los&lt;br /&gt;
-- elementos de la lista xs. Por ejemplo,&lt;br /&gt;
--   dec2ent [2,3,4,5]  ==  2345&lt;br /&gt;
--   dec2ent [1..9]     ==  123456789&lt;br /&gt;
--&lt;br /&gt;
-- Defie esta función&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- 1) por comprensión,              &lt;br /&gt;
dec2entC :: [Integer] -&amp;gt; Integer&lt;br /&gt;
dec2entC xs = sum [x * (10^y) | (x, y) &amp;lt;- zip (reverse xs) [0,1..] ]&lt;br /&gt;
&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)&lt;br /&gt;
dec2entS :: [Integer] -&amp;gt; Integer&lt;br /&gt;
dec2entS xs = read (map intToDigit (map fromIntegral xs))&lt;br /&gt;
&lt;br /&gt;
dec2entS&amp;#039; :: [Integer] -&amp;gt; Integer&lt;br /&gt;
dec2entS&amp;#039; xs = read (filter isDigit (show xs))&lt;br /&gt;
&lt;br /&gt;
dec2entS&amp;#039;&amp;#039; :: [Integer] -&amp;gt; Integer&lt;br /&gt;
dec2entS&amp;#039;&amp;#039; xs = sum (map (\(x,n) -&amp;gt; x*10^n) (zip xs [n,(n-1)..]) )&lt;br /&gt;
  where n = length xs - 1&lt;br /&gt;
&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
dec2entR :: [Integer] -&amp;gt; Integer&lt;br /&gt;
dec2entR xs = dec2entRaux (reverse xs)&lt;br /&gt;
dec2entRaux [] = 0&lt;br /&gt;
dec2entRaux (x:xs) = x + 10*dec2entRaux xs&lt;br /&gt;
&lt;br /&gt;
dec2entR&amp;#039; :: [Integer] -&amp;gt; Integer&lt;br /&gt;
dec2entR&amp;#039; [x] = x&lt;br /&gt;
dec2entR&amp;#039; (x:xs) = x*10^(length xs) + dec2entR xs&lt;br /&gt;
&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
dec2entP :: [Integer] -&amp;gt; Integer&lt;br /&gt;
dec2entP xs = foldr (\ x y -&amp;gt; 10*y + x) 0 (reverse xs)&lt;br /&gt;
&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
-- Ejercicio 4. Se considera la función&lt;br /&gt;
--     diferencia :: Eq a =&amp;gt; [a] -&amp;gt; [a] -&amp;gt; [a]&lt;br /&gt;
-- tal que (diferencia xs ys) es la diferencia entre los conjuntos xs e&lt;br /&gt;
-- ys; es decir, el conjunto de los elementos de la lista xs que no se&lt;br /&gt;
-- encuentran en la lista ys. Por ejemplo,&lt;br /&gt;
--   diferencia [2,3,5,6] [5,2,7]  ==  [3,6]&lt;br /&gt;
--   diferencia [1,3,5,7] [2,4,6]  ==  [1,3,5,7]&lt;br /&gt;
--   diferencia [1,3] [1..9]       ==  []&lt;br /&gt;
--&lt;br /&gt;
-- Define esta función&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
diferenciaC :: Eq a =&amp;gt; [a] -&amp;gt; [a] -&amp;gt; [a]&lt;br /&gt;
diferenciaC xs ys = [x | x &amp;lt;- xs, not (elem x ys)]&lt;br /&gt;
&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)&lt;br /&gt;
diferenciaOS :: Eq a =&amp;gt; [a] -&amp;gt; [a] -&amp;gt; [a]&lt;br /&gt;
diferenciaOS xs ys = filter (\ x -&amp;gt; not (elem x ys)) xs&lt;br /&gt;
&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
diferenciaR :: Eq a =&amp;gt; [a] -&amp;gt; [a] -&amp;gt; [a]&lt;br /&gt;
diferenciaR [] _ = []&lt;br /&gt;
diferenciaR xs [] = xs&lt;br /&gt;
diferenciaR (x:xs) ys&lt;br /&gt;
    | elem x ys         = diferenciaR xs ys&lt;br /&gt;
    | otherwise         = x:diferenciaR xs ys&lt;br /&gt;
&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
diferenciaP :: Eq a =&amp;gt; [a] -&amp;gt; [a] -&amp;gt; [a]&lt;br /&gt;
diferenciaP xs ys = foldr (\x acc -&amp;gt; if elem x ys then acc else x:acc) [] xs&lt;br /&gt;
&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
-- Ejercicio 5. Se considera la función&lt;br /&gt;
--   primerosYultimos :: [[a]] -&amp;gt; ([a],[a])&lt;br /&gt;
-- tal que (primerosYultimos xss) es el par formado por la lista de los&lt;br /&gt;
-- primeros elementos de las listas no vacías de xss y la lista de los&lt;br /&gt;
-- últimos elementos de las listas no vacías de xss. Por ejemplo,&lt;br /&gt;
--   primerosYultimos [[1,2],[5,3,4],[],[9]]  ==  ([1,5,9],[2,4,9])&lt;br /&gt;
--   primerosYultimos [[1,2],[1,2,3],[1..4]]  ==  ([1,1,1],[2,3,4])&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- Define esta función&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
primerosYultimosC :: [[a]] -&amp;gt; ([a],[a])&lt;br /&gt;
primerosYultimosC xss = unzip [(head xs, last xs) | xs &amp;lt;- xss, not (null xs)]&lt;br /&gt;
&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)&lt;br /&gt;
primerosYultimosS :: [[a]] -&amp;gt; ([a],[a])&lt;br /&gt;
primerosYultimosS xss = unzip (map (\ x -&amp;gt; (head x, last x)) (filter (not.null) xss))&lt;br /&gt;
&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
primerosYultimosR :: [[a]] -&amp;gt; ([a],[a])&lt;br /&gt;
primerosYultimosR xss = unzip (primerosYultimosR&amp;#039; xss)&lt;br /&gt;
primerosYultimosR&amp;#039; [] = []&lt;br /&gt;
primerosYultimosR&amp;#039; (xs:xss)&lt;br /&gt;
  | null xs = primerosYultimosR&amp;#039; xss&lt;br /&gt;
  | otherwise = (head xs, last xs) : primerosYultimosR&amp;#039; xss&lt;br /&gt;
&lt;br /&gt;
primerosYultimosR2 :: [[a]] -&amp;gt; ([a],[a])&lt;br /&gt;
primerosYultimosR2 xss = (primerosR xss, ultimosR xss)&lt;br /&gt;
&lt;br /&gt;
primerosR [] = []&lt;br /&gt;
primerosR (xs:xss) | null xs    = primerosR xss&lt;br /&gt;
                   | otherwise  = [head xs] ++ primerosR xss&lt;br /&gt;
ultimosR [] = []&lt;br /&gt;
ultimosR (xs:xss) | null xs    = ultimosR xss&lt;br /&gt;
                  | otherwise  = [last xs] ++ ultimosR xss&lt;br /&gt;
                  &lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
primerosYultimosP xss = unzip (foldr (\ x y -&amp;gt; (head x, last x) : y) [] (filter (/= []) xss))&lt;br /&gt;
&lt;br /&gt;
primerosYultimosP2 :: [[a]] -&amp;gt; ([a],[a])&lt;br /&gt;
primerosYultimosP2 xss = (primerosPR xss, ultimosPR xss) &lt;br /&gt;
&lt;br /&gt;
primerosPR xss = foldr f [] xss&lt;br /&gt;
              where f x recu | null x     = recu&lt;br /&gt;
                             | otherwise  = [head x] ++ recu&lt;br /&gt;
ultimosPR xss = foldr f [] xss&lt;br /&gt;
              where f x recu | null x     = recu&lt;br /&gt;
                             | otherwise  = [last x] ++ recu&lt;br /&gt;
                             &lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
-- Ejercicio 6. Una lista hermanada es una lista de números estrictamente&lt;br /&gt;
-- positivos en la que cada elemento tiene algún factor primo en común con el&lt;br /&gt;
-- siguiente, en caso de que exista, o alguno de los dos es un 1. Por ejemplo,&lt;br /&gt;
-- [2,6,3,9,1,5] es una lista hermanada.&lt;br /&gt;
&lt;br /&gt;
-- Se considera la función&lt;br /&gt;
--    hermanada :: [Int] -&amp;gt; Bool&lt;br /&gt;
-- tal que (hermanada xs) comprueba que la lista xs es hermanada según la&lt;br /&gt;
-- definición anterior. Por ejemplo,&lt;br /&gt;
--    hermanada [2,6,3,9,1,5]  ==  True&lt;br /&gt;
--    hermanada [2,3,5]        ==  False&lt;br /&gt;
--&lt;br /&gt;
-- Se pide definir esta función&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
-- Nota: Usa la función &amp;#039;gcd&amp;#039;&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- hermanos es lo contrario que ser co-primos. Con la siguiente comparación&lt;br /&gt;
-- basta&lt;br /&gt;
hermanos :: Integral a =&amp;gt; a -&amp;gt; a -&amp;gt; Bool&lt;br /&gt;
hermanos x y = x == 1 || y == 1 || (gcd x y /= 1)&lt;br /&gt;
&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
hermanadaC :: [Int] -&amp;gt; Bool&lt;br /&gt;
hermanadaC xs = and [hermanos x y | (x,y) &amp;lt;- zip xs (tail xs)]&lt;br /&gt;
&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)&lt;br /&gt;
hermanadaOS :: [Int] -&amp;gt; Bool&lt;br /&gt;
hermanadaOS xs = all (\ (x,y) -&amp;gt; hermanos x y) (zip xs (tail xs))&lt;br /&gt;
&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
hermanadaR :: [Int] -&amp;gt; Bool&lt;br /&gt;
hermanadaR [] = True&lt;br /&gt;
hermanadaR (x:[]) = True&lt;br /&gt;
hermanadaR (x:y:xs) = (hermanos x y) &amp;amp;&amp;amp; (hermanadaR (y:xs))&lt;br /&gt;
&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
hermanadaP :: [Int] -&amp;gt; Bool&lt;br /&gt;
hermanadaP xs = foldr (\ (x,y) z -&amp;gt; (hermanos x y) &amp;amp;&amp;amp; z) True (zip xs (tail xs))&lt;br /&gt;
&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
-- Ejercicio 7. Un elemento de una lista es permanente si ninguno de los que&lt;br /&gt;
-- vienen a continuación en la lista es mayor que él. Consideramos la función&lt;br /&gt;
--   permanentes :: [Int] -&amp;gt; [Int]&lt;br /&gt;
-- tal que (permanentes xs) es la lista de los elementos permanentes de la&lt;br /&gt;
-- lista xs. Por ejemplo,&lt;br /&gt;
--   permanentes [80,1,7,8,4]  ==  [80,8,4]&lt;br /&gt;
&lt;br /&gt;
-- Se pide definir esta función&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
-- ---------------------------------------------------------------------------&lt;br /&gt;
-- Nota: Usa la función &amp;#039;tails&amp;#039; de Data.List.&lt;br /&gt;
-- ----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
head_permanente :: Ord a =&amp;gt; [a] -&amp;gt; Bool&lt;br /&gt;
head_permanente (y:[]) = True&lt;br /&gt;
head_permanente (y:ys) = (maximum ys &amp;lt; y)&lt;br /&gt;
&lt;br /&gt;
-- 1) por comprensión,&lt;br /&gt;
permanentesC :: [Int] -&amp;gt; [Int]&lt;br /&gt;
permanentesC xs = [y | (y:ys) &amp;lt;- tails xs, head_permanente (y:ys)]&lt;br /&gt;
&lt;br /&gt;
-- 2) por orden superior (map, filter, ...)               &lt;br /&gt;
permanentesS :: [Int] -&amp;gt; [Int]&lt;br /&gt;
permanentesS xs = map head (filter head_permanente (init (tails xs)))&lt;br /&gt;
&lt;br /&gt;
-- Por composición de funciones&lt;br /&gt;
permanentesS&amp;#039; :: [Int] -&amp;gt; [Int]&lt;br /&gt;
permanentesS&amp;#039; = (map head) .  (filter head_permanente) .  init . tails&lt;br /&gt;
&lt;br /&gt;
-- 3) por recursión,&lt;br /&gt;
permanentesR :: [Int] -&amp;gt; [Int]&lt;br /&gt;
permanentesR [] = []&lt;br /&gt;
permanentesR (x:xs)&lt;br /&gt;
  | head_permanente (x:xs) = x:permanentesR xs&lt;br /&gt;
  | otherwise   = permanentesR xs&lt;br /&gt;
&lt;br /&gt;
-- 4) por plegado (con &amp;#039;foldr&amp;#039;).&lt;br /&gt;
permanentesP :: [Int] -&amp;gt; [Int]&lt;br /&gt;
permanentesP xs = foldr (\ys acc -&amp;gt; if head_permanente ys then (head ys):acc else acc) [] (init (tails xs))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- ---------------------------------------------------------------------&lt;br /&gt;
-- Ejercicio 8. Un número entero positivo n es muy primo si es n primo&lt;br /&gt;
-- y todos los números que resultan de ir suprimimiendo la última cifra&lt;br /&gt;
-- también son primos. Por ejemplo, 7193 es muy primo pues los números&lt;br /&gt;
-- 7193, 719, 71 y 7 son todos primos. &lt;br /&gt;
-- &lt;br /&gt;
-- Define la función &lt;br /&gt;
--    muyPrimo :: Integer -&amp;gt; Bool&lt;br /&gt;
-- que (muyPrimo n) se verifica si n es muy primo. Por ejemplo,&lt;br /&gt;
--    muyPrimo 7193  == True&lt;br /&gt;
--    muyPrimo 71932 == False&lt;br /&gt;
-- --------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
muyPrimo :: Integer -&amp;gt; Bool&lt;br /&gt;
muyPrimo 0 = True&lt;br /&gt;
muyPrimo n = isPrime n &amp;amp;&amp;amp; (muyPrimo (div n 10))&lt;br /&gt;
&lt;br /&gt;
-- ---------------------------------------------------------------------&lt;br /&gt;
-- ¿Cuántos números de cinco cifras son muy primos?&lt;br /&gt;
-- ---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- El cálculo es&lt;br /&gt;
-- length $ filter muyPrimo [10^4..(10^5-1)]&lt;br /&gt;
-- &amp;gt; 15&lt;br /&gt;
-- ---------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdelamor</name></author>
	</entry>
</feed>