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
import Data.List(sort) | |
import Math.Algebra.Group.PermutationGroup(fromPairs) | |
data Op = DN | UP deriving (Show, Eq, Ord) | |
paso :: (Integral a) => (a -> a) -> a -> a | |
paso hazpar x = if odd x then div (hazpar x) 2 else div x 2 | |
-- 'take n $ serieInfinita binarios x' da una representación binaria de | |
-- x truncada a n bits, 'DN' es 0, 'UP' es 1, el primer bit en la cadena |
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
import Data.Numbers.Primes(primes) | |
import Data.List(sort, sortBy) | |
rad :: Integer -> Integer | |
rad n = product $ f n primes where | |
f :: Integer -> [Integer] -> [Integer] | |
f 1 _ = [] | |
f x (y:ys) = if mod x y == 0 | |
then y : f (remove y x) ys | |
else f x ys |
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
import Haskore.Basic.Duration | |
import Haskore.Interface.MIDI.Render | |
import Haskore.Melody | |
import Haskore.Basic.Interval | |
import Haskore.Music.GeneralMIDI as GM | |
import Haskore.Basic.Scale | |
import Haskore.Basic.Tempo | |
import Haskore.Basic.Pitch as BP | |
import qualified Haskore.Music as Music |
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
import Haskore.Basic.Duration | |
import Haskore.Interface.MIDI.Render | |
import Haskore.Melody | |
import Haskore.Basic.Interval | |
import Haskore.Music.GeneralMIDI as GM | |
import Haskore.Basic.Scale | |
import Haskore.Basic.Tempo | |
import Haskore.Basic.Pitch as BP | |
import qualified Haskore.Music as Music |
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
-- para construir: "ghci yidl.hs" seguido de "render todo" crea "yidl.mid" | |
import Haskore.Basic.Duration | |
import Haskore.Interface.MIDI.Render | |
import Haskore.Melody | |
import Haskore.Basic.Interval | |
import Haskore.Music.GeneralMIDI as GM | |
import Haskore.Basic.Scale | |
import Haskore.Basic.Tempo | |
import Haskore.Basic.Pitch as BP |
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
import Haskore.Interface.MIDI.Render | |
import Haskore.Melody | |
import Haskore.Music.GeneralMIDI as GM | |
import qualified Haskore.Music as Music | |
test m = fileFromGeneralMIDIMusic "test.mid" $ GM.fromMelodyNullAttr AcousticGrandPiano m | |
riff = line [utp, mi, sol, ti] where | |
utp = chord [ut, mi, sol] | |
ut = c 2 en () |
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
import Data.Maybe (fromJust, catMaybes) | |
import Data.List (subsequences, findIndex, findIndices) | |
import Data.Word(Word8) | |
import qualified Data.ByteString.Lazy as BL | |
import Data.Binary.Put | |
data Op = UP | DN deriving (Show, Eq) | |
-- Generalizaciones (limpiar; mala estructura, usar folds) |
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
import Data.List (sortBy) | |
data Op = UP | DN deriving (Show, Eq) | |
serie :: Integer -> [Op] | |
serie 1 = cycle [UP,DN] | |
serie x | |
| odd x = UP : (serie (div ((3*x)+1) 2)) | |
| even x = DN : (serie (div x 2)) |
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
import subprocess as sp | |
def instalados(): | |
proceso = sp.Popen('pkg_info', stdout=sp.PIPE) | |
lineas = proceso.communicate()[0].splitlines() | |
return map (lambda k: k.split()[0], lineas) # solo la primera palabra | |
def filtra(xs): | |
return filter(lambda k: len(k) > 0 and k.find('Required') != 0 and k.find('Information') != 0 and k[0] != '\n', 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
paquetes :: IO [String] | |
paquetes = readFile "packages.log" >>= (\k -> return $ lines k) >>= (\k -> return $ map (takeWhile (/= ' ')) k) | |
flechas :: IO [String] | |
flechas = readFile "portgraph.dot" >>= (\k -> return $ lines k) >>= (\k -> return $ init $ tail k) | |
-- "foo-1.2.3" -> "bar-baz-2.0.0" | |
-- se convierte en (foo, bar-baz) | |
-- se considera que no hay paquetes con subcadena "-<num>" en el nombre | |
flecha_a_par :: String -> (String, String) |