This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* archivo, test.c */ | |
#include <stdio.h> | |
void main () { | |
char c; | |
c = c & 0; | |
printf("The value of c is %d", (int)c); | |
int j = 255; | |
c = (c | j); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Recurrencia a(n+2) + 2*a(n+1) + 2*a(n) = 0, n >= 0, a(0) = 1, a(1) = 3 | |
[GP] (recuperando las raíces) | |
? polroots(x^2+2*x+2) | |
%1 = [-1.000000000000000000000000000 - 1.000000000000000000000000000*I, -1.000000000000000000000000000 + 1.000000000000000000000000000*I]~ | |
[Haskell] | |
(construyendo la recurrencia directamente) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PARI/GP | |
La serie formal generada por (3*x^2 + 5)/((1-x^2)*(1-x)^2) hasta x^99, el O(x^n) | |
representa el error y al sumarlo GP entiende que es serie en lugar de solamente | |
función racional | |
? p = (3*x^2 + 5)/((1-x^2)*(1-x)^2) + O(x^100) | |
Extrae el coeficiente de x^45 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- CollatzBool.hs | |
module CollatzBool where | |
porTresMasUno :: [Bool] -> [Bool] | |
porTresMasUno xs = False : ys ++ residuo where | |
cs = True : zipWith3 gc cs (tail xs) xs | |
gc b = if b then (||) else (&&) | |
ys = zipWith3 gy cs (tail xs ++ [False]) xs | |
gy p q r = (p /= q) /= r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
porTresMasUno :: [Bool] -> [Bool] | |
porTresMasUno xs = False : ys ++ residuo where | |
cs = True : zipWith3 gc cs (tail xs) xs | |
gc b = if b then (||) else (&&) | |
ys = zipWith3 gy cs (tail xs ++ [False]) xs | |
gy p q r = (p /= q) /= r | |
residuo = if last cs then [True] else [] | |
serie :: String -> [[Bool]] | |
serie s = takeWhile (not.alto) $ iterate paso $ leer s where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- head = LSB | |
decimal_a_bool :: Integer -> [Bool] | |
decimal_a_bool 1 = [True] | |
decimal_a_bool n = odd n : decimal_a_bool (div n 2) | |
bool_a_decimal :: [Bool] -> Integer | |
-- La cadena vacía no tiene representación | |
bool_a_decimal [] = error "Sin entrada" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- LFSR, en formato compatible con | |
-- http://homepage.mac.com/afj/taplist.html | |
-- uso (en ghci): | |
-- > let t = ciclo 7 $ drop 7 $ leer $ generar "1111111" [7,6,4,2] | |
-- "1111111" es cadena inicial con 7 registros | |
-- [7, 6, 4, 2] es cuarteta en http://homepage.mac.com/afj/7bits.txt | |
-- 'ciclo 7' se detiene cuando se repite la secuencia de los 7 primeros símbolos | |
-- > t | |
-- "00111110110111000000101000011011 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zipWithN f = foldl1 (zipWith f) | |
generar :: String -> [Int] -> [Bool] | |
generar inicial indices = ts where | |
ts = xs ++ zipWithN (/=) (g indices) | |
xs = map (== '1') inicial | |
g = map ((flip drop) ts) | |
leer n xs = take n $ map (\k -> if k then '1' else '0') xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Como recurrencias, operando sobre listas infinitas paralelas | |
-- con función x1 + x3 | |
t1 = True : False : False : True : zipWith (/=) (drop 1 t1) (drop 3 t1) | |
-- x1 + x2 + x3 | |
t2 = True : False : False : True : zipWith3 g (drop 1 t2) (drop 2 t2) (drop 3 t2) where | |
g a b c = (a /= b) /= c | |
leer n xs = take n $ map (\k -> if k then '1' else 0') xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
takeUntil :: (a -> Bool) -> [a] -> [a] | |
takeUntil _ [] = [] | |
takeUntil p (x:xs) | |
| (not.p) x = x : takeUntil p xs | |
| otherwise = [x] | |
paso :: (Integer, Integer, Integer, Integer) -> (Integer, Integer, Integer, Integer) | |
paso (numimpares,secuencia,x,reg) = (numimpares',secuencia',x',reg') where | |
x' = quot x 2 | |
corregido = if odd x then reg + 3^numimpares else reg |