Skip to content

Instantly share code, notes, and snippets.

View kmels's full-sized avatar

Carlos López kmels

  • Guatemala, Guatemala
View GitHub Profile
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
data Expr :: * -> * where
Int :: Int -> Expr Int
Bool :: Bool -> Expr Bool
IsZero :: Expr Int -> Expr Bool
-- Plus :: (* -> *) -> (* -> *) -> (* ->
If :: Expr Bool -> Expr a -> Expr a -> Expr a
-- tests if an image is valid and, if it is, returns the resolution of the picture as a pair of the x-resolution and the y-resolution. An image is valid if all its pixels are valid and if all the rows have equally many columns.
ANTES
-----------------------------
validImage rows@(firstRow:nextRow:rrs) =
if (isValidRow firstRow && length firstRow == length nextRow && (isJust $ validImage (nextRow:rrs))) then
Just (length firstRow, length rows)
else
Nothing
validImage rows@(r:rs) = if isValidRow r && (isJust $ validImage rs) then Just (length r, length rows) else Nothing
-- tests if an image is valid and, if it is, returns the resolution of the picture as a pair of the x-resolution and the y-resolution. An image is valid if all its pixels are valid and if all the rows have equally many columns.
ANTES
-----------------------------
validImage rows@(firstRow:nextRow:rrs) =
if (isValidRow firstRow && length firstRow == length nextRow && (isJust $ validImage (nextRow:rrs))) then
Just (length firstRow, length rows)
else
Nothing
validImage rows@(r:rs) = if isValidRow r && (isJust $ validImage rs) then Just (length r, length rows) else Nothing
@kmels
kmels / xmonad.hs
Created June 6, 2012 14:52
xmonad.hs to use with launcher
import XMonad
import Data.Monoid
import System.Exit
import XMonad.Config.Gnome
import XMonad.Util.Replace
import XMonad.Actions.Search
import qualified XMonad.Actions.Submap as SM
import qualified XMonad.StackSet as W
#Punto fijo, que avisa si la sucesion de numeros dada la ecuacion de recurrencia G(x) no es una contraccion, i.e. si | G'(x) | >= 1. Hay que mandarle la derivada de G(x), i.e. G_ en el parametro
def PuntoFijoAPruebaDeMuladas(G,G_,x0,e):
if abs(G_(x0)) >= 1:
print "Esta funcion G(x) esta tricky, la derivada evaluada en x=",x, " es mayor que 1, por lo que se podria salir de la recta f(x)=x y no converger"
else:
print "x_i: " , x0, " G(x_i): ", G(x0)
x0 = G(x0)
return x