Skip to content
{{ message }}

Instantly share code, notes, and snippets.

# joseanpg joseanpg

Last active Feb 12, 2016
PureScript: Determinando el js-tipo de Aff a Aff a = (a -> (), Error-> ()) -> Canceler )
View 00-InferenciaDelTipoDeAff.hs
 https://github.com/slamdata/purescript-aff/blob/master/src/Control/Monad/Aff.purs -- | A canceler is asynchronous function that can be used to attempt the -- | cancelation of a computation. Returns a boolean flag indicating whether -- | or not the cancellation was successful. Many computations may be composite, -- | in such cases the flag indicates whether any part of the computation was -- | successfully canceled. The flag should not be used for communication. newtype Canceler e = Canceler (Error -> Aff e Boolean)
Last active Sep 8, 2015
Basic Polymorphic Typechecking ~ Luca Cardelli 1987
View cardelli-definition.mod
 (** http://lucacardelli.name/Papers/BasicTypechecking.pdf **) (** Modula 2 **) (***************************************************************************) (**************************** DEFINITION MODULES ***************************) (***************************************************************************) (***************************************************************************) DEFINITION MODULE ErrorMod; PROCEDURE Msg(msg: ARRAY OF CHAR);
Created Feb 6, 2015
helpingraf.hs
View helpingraf.hs
 import Data.List -- alphabil = [0,0,0,0,1,1,1,2,2,2] -- alphanob = [0,0,0,0,3,3,3,4,4,4] alphabil = [0,0,0,1,1,2,2] alphanob = [0,0,0,3,3,4,4] betabil = {-nub-} (permutations alphabil) betanob = {-nub-} (permutations alphanob)
Created Feb 6, 2015
Y
View yfix.hs
 newtype Mu a = In (Mu a -> a) out :: Mu a -> (Mu a -> a) out (In f) = f omega = \f->(out f) f psi = \h -> \f-> h ((out f) f) yfix = \i-> omega (In (psi i)) factorial = yfix (\g-> \n->if n < 2 then 1 else n*( g (n-1)))
Created Feb 6, 2015
case everything
View let_is_case.hs
 module Letiscase where data Tipo = TipoUno Int | TipoDos Int f (TipoUno x) = x f (TipoDos x) = x g t = case t of TipoUno x -> x
Last active Aug 29, 2015
@Jose_A_Alonso Exercitium: Particiones de enteros positivos
View 01-particiones.hs
 -- www.glc.us.es/~jalonso/exercitium/particiones-de-enteros-positivos/ zen :: ([a] -> [a]) -> [a] -> [a] -> [a] zen f a b = let a' = f a b' = b ++ a in case a' of [] -> b' _ -> zen f a' b'
Last active Aug 29, 2015
@Jose_A_Alonso Exercitium: Mínimo producto escalar
View 01-menorProductoEscalarPorFuerza.hs
 -- http://www.glc.us.es/~jalonso/exercitium/minimo-producto-escalar/ import Data.List ----------------------------------------------------------------------------------------- a <·> b = sum (zipWith (*) a b) -----------------------------------------------------------------------------------------
Created Feb 3, 2015
@Jose_A_Alonso Exercitium: Mayor capicúa producto de dos números de n cifras
View mayorCapicuaP.hs
 -- www.glc.us.es/~jalonso/exercitium/mayor-capicua-producto-de-dos-numeros-de-n-cifras mayorCapicuaP n = alpha 0 (t-1) where t = 10^n b = div t 10 alpha a x | x > b = let a' = case beta x of Just z -> max z a Nothing -> a in alpha a' (x-1)
Last active Aug 29, 2015
Experimentando con wescheme.org y codeworld.info (va ganando haskell)
View casa.hs
 main = animationOf mover pared = color(solidRectangle (4,2),light yellow) tejado = color(solidPolygon[(-2,1),(0,2),(2,1)],red) puerta = translate(color(solidRectangle(0.6,1),brown),0,-0.5) ventana1 = translate(color(solidRectangle(0.6,0.6),light blue),-1,0) ventana2 = translate(color(solidRectangle(0.6,0.6),light blue),1,0) mover a = rotate (casa,100*a)
Last active Aug 29, 2015
Difference between Lambda Expression and Anonymous class.
View 00-ObservableSet.java
 import java.util.Set; import java.util.List; import java.util.ArrayList; interface SetObserver { void added(ObservableSet set, E element); } public class ObservableSet {